Skip to content

Commit

Permalink
fixed conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS committed Feb 26, 2020
2 parents e4bba77 + d5a9cd5 commit 86f8776
Show file tree
Hide file tree
Showing 40 changed files with 888 additions and 193 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,7 @@ env:
- TEST=API
- TEST=E2E LANG="c_lang or python or java or go_lang or javascript or php"
- TEST=E2E LANG="c_sharp or visual_basic or powershell"
- TEST=E2E LANG="r_lang"
- TEST=E2E LANG="r_lang or dart"

before_install:
- bash .travis/setup.sh
Expand Down
8 changes: 8 additions & 0 deletions .travis/setup.sh
Expand Up @@ -29,3 +29,11 @@ if [[ $LANG == *"php"* ]]; then
sudo apt-get update
sudo apt-get install --no-install-recommends -y php
fi

# Install Dart. (https://dart.dev/get-dart)
if [[ $LANG == *"dart"* ]]; then
sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
sudo apt-get update
sudo apt-get install --no-install-recommends -y dart
fi
5 changes: 4 additions & 1 deletion Dockerfile
Expand Up @@ -7,6 +7,8 @@ RUN apt-get update && \
add-apt-repository ppa:deadsnakes/ppa && \
wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
apt-get update && \
apt-get install --no-install-recommends -y \
gcc \
Expand All @@ -20,7 +22,8 @@ RUN apt-get update && \
dotnet-sdk-3.0 \
powershell \
r-base \
php && \
php \
dart && \
rm -rf /var/lib/apt/lists/*

WORKDIR /m2cgen
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1,5 +1,5 @@
include LICENSE
recursive-include m2cgen VERSION.txt
recursive-include m2cgen linear_algebra.*
recursive-include m2cgen tanh.bas
recursive-include m2cgen tanh.*
global-exclude *.py[cod]
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -7,7 +7,7 @@
[![PyPI Version](https://img.shields.io/pypi/v/m2cgen.svg?logo=pypi&logoColor=white)](https://pypi.org/project/m2cgen)
[![Downloads](https://pepy.tech/badge/m2cgen)](https://pepy.tech/project/m2cgen)

**m2cgen** (Model 2 Code Generator) - is a lightweight library which provides an easy way to transpile trained statistical models into a native code (Python, C, Java, Go, JavaScript, Visual Basic, C#, PowerShell, R, PHP).
**m2cgen** (Model 2 Code Generator) - is a lightweight library which provides an easy way to transpile trained statistical models into a native code (Python, C, Java, Go, JavaScript, Visual Basic, C#, PowerShell, R, PHP, Dart).

* [Installation](#installation)
* [Supported Languages](#supported-languages)
Expand All @@ -28,6 +28,7 @@ pip install m2cgen

- C
- C#
- Dart
- Go
- Java
- JavaScript
Expand All @@ -41,7 +42,7 @@ pip install m2cgen

| | Classification | Regression |
| --- | --- | --- |
| **Linear** | <ul><li>scikit-learn<ul><li>LogisticRegression</li><li>LogisticRegressionCV</li><li>PassiveAggressiveClassifier</li><li>Perceptron</li><li>RidgeClassifier</li><li>RidgeClassifierCV</li><li>SGDClassifier</li></ul></li><li>lightning<ul><li>AdaGradClassifier</li><li>CDClassifier</li><li>FistaClassifier</li><li>SAGAClassifier</li><li>SAGClassifier</li><li>SDCAClassifier</li><li>SGDClassifier</li></ul></li></ul> | <ul><li>scikit-learn<ul><li>ARDRegression</li><li>BayesianRidge</li><li>ElasticNet</li><li>ElasticNetCV</li><li>HuberRegressor</li><li>Lars</li><li>LarsCV</li><li>Lasso</li><li>LassoCV</li><li>LassoLars</li><li>LassoLarsCV</li><li>LassoLarsIC</li><li>LinearRegression</li><li>OrthogonalMatchingPursuit</li><li>OrthogonalMatchingPursuitCV</li><li>PassiveAggressiveRegressor</li><li>RANSACRegressor(only supported regression estimators can be used as a base estimator)</li><li>Ridge</li><li>RidgeCV</li><li>SGDRegressor</li><li>TheilSenRegressor</li></ul><li>StatsModels<ul><li>Generalized Least Squares (GLS)</li><li>Ordinary Least Squares (OLS)</li><li>Weighted Least Squares (WLS)</li></ul><li>lightning<ul><li>AdaGradRegressor</li><li>CDRegressor</li><li>FistaRegressor</li><li>SAGARegressor</li><li>SAGRegressor</li><li>SDCARegressor</li></ul></li></ul> |
| **Linear** | <ul><li>scikit-learn<ul><li>LogisticRegression</li><li>LogisticRegressionCV</li><li>PassiveAggressiveClassifier</li><li>Perceptron</li><li>RidgeClassifier</li><li>RidgeClassifierCV</li><li>SGDClassifier</li></ul></li><li>lightning<ul><li>AdaGradClassifier</li><li>CDClassifier</li><li>FistaClassifier</li><li>SAGAClassifier</li><li>SAGClassifier</li><li>SDCAClassifier</li><li>SGDClassifier</li></ul></li></ul> | <ul><li>scikit-learn<ul><li>ARDRegression</li><li>BayesianRidge</li><li>ElasticNet</li><li>ElasticNetCV</li><li>HuberRegressor</li><li>Lars</li><li>LarsCV</li><li>Lasso</li><li>LassoCV</li><li>LassoLars</li><li>LassoLarsCV</li><li>LassoLarsIC</li><li>LinearRegression</li><li>OrthogonalMatchingPursuit</li><li>OrthogonalMatchingPursuitCV</li><li>PassiveAggressiveRegressor</li><li>RANSACRegressor(only supported regression estimators can be used as a base estimator)</li><li>Ridge</li><li>RidgeCV</li><li>SGDRegressor</li><li>TheilSenRegressor</li></ul><li>StatsModels<ul><li>Generalized Least Squares (GLS)</li><li>Generalized Least Squares with AR Errors (GLSAR)</li><li>Ordinary Least Squares (OLS)</li><li>Weighted Least Squares (WLS)</li></ul><li>lightning<ul><li>AdaGradRegressor</li><li>CDRegressor</li><li>FistaRegressor</li><li>SAGARegressor</li><li>SAGRegressor</li><li>SDCARegressor</li></ul></li></ul> |
| **SVM** | <ul><li>scikit-learn<ul><li>LinearSVC</li><li>NuSVC</li><li>SVC</li></ul></li><li>lightning<ul><li>LinearSVC</li></ul></li></ul> | <ul><li>scikit-learn<ul><li>LinearSVR</li><li>NuSVR</li><li>SVR</li></ul></li><li>lightning<ul><li>LinearSVR</li></ul></li></ul> |
| **Tree** | <ul><li>DecisionTreeClassifier</li><li>ExtraTreeClassifier</li></ul> | <ul><li>DecisionTreeRegressor</li><li>ExtraTreeRegressor</li></ul> |
| **Random Forest** | <ul><li>ExtraTreesClassifier</li><li>LGBMClassifier(rf booster only)</li><li>RandomForestClassifier</li><li>XGBRFClassifier(binary only, multiclass is not supported yet)</li></ul> | <ul><li>ExtraTreesRegressor</li><li>LGBMRegressor(rf booster only)</li><li>RandomForestRegressor</li><li>XGBRFRegressor</li></ul> |
Expand Down
6 changes: 3 additions & 3 deletions generated_code_examples/php/classification/random_forest.php
@@ -1,12 +1,12 @@
<?php
function add_vectors(array $v1, array $v2) {
function addVectors(array $v1, array $v2) {
$result = array();
for ($i = 0; $i < count($v1); ++$i) {
$result[] = $v1[$i] + $v2[$i];
}
return $result;
}
function mul_vector_number(array $v1, $num) {
function mulVectorNumber(array $v1, $num) {
$result = array();
for ($i = 0; $i < count($v1); ++$i) {
$result[] = $v1[$i] * $num;
Expand Down Expand Up @@ -50,5 +50,5 @@ function score(array $input) {
}
}
}
return add_vectors(mul_vector_number($var0, 0.5), mul_vector_number($var1, 0.5));
return addVectors(mulVectorNumber($var0, 0.5), mulVectorNumber($var1, 0.5));
}
@@ -1,15 +1,15 @@
Module Model
Function score(ByRef input_vector() As Double) As Double()
Function Score(ByRef inputVector() As Double) As Double()
Dim var0() As Double
If (input_vector(2)) <= (2.6) Then
If (inputVector(2)) <= (2.6) Then
Dim var1(2) As Double
var1(0) = 1.0
var1(1) = 0.0
var1(2) = 0.0
var0 = var1
Else
If (input_vector(2)) <= (4.8500004) Then
If (input_vector(3)) <= (1.6500001) Then
If (inputVector(2)) <= (4.8500004) Then
If (inputVector(3)) <= (1.6500001) Then
Dim var2(2) As Double
var2(0) = 0.0
var2(1) = 1.0
Expand All @@ -23,7 +23,7 @@ Function score(ByRef input_vector() As Double) As Double()
var0 = var3
End If
Else
If (input_vector(3)) <= (1.75) Then
If (inputVector(3)) <= (1.75) Then
Dim var4(2) As Double
var4(0) = 0.0
var4(1) = 0.42857142857142855
Expand All @@ -38,6 +38,6 @@ Function score(ByRef input_vector() As Double) As Double()
End If
End If
End If
score = var0
Score = var0
End Function
End Module
32 changes: 16 additions & 16 deletions generated_code_examples/visual_basic/classification/lightgbm.vb
@@ -1,8 +1,8 @@
Module Model
Function score(ByRef input_vector() As Double) As Double()
Function Score(ByRef inputVector() As Double) As Double()
Dim var0 As Double
If (input_vector(2)) > (1.8) Then
If (input_vector(2)) > (4.250000000000001) Then
If (inputVector(2)) > (1.8) Then
If (inputVector(2)) > (4.250000000000001) Then
var0 = -1.1736122903444903
Else
var0 = -1.1633850173886202
Expand All @@ -11,8 +11,8 @@ Function score(ByRef input_vector() As Double) As Double()
var0 = -0.9486122853153485
End If
Dim var1 As Double
If (input_vector(2)) > (1.8) Then
If (input_vector(1)) > (3.0500000000000003) Then
If (inputVector(2)) > (1.8) Then
If (inputVector(1)) > (3.0500000000000003) Then
var1 = -0.06193194743580539
Else
var1 = -0.07237070828653688
Expand All @@ -23,8 +23,8 @@ Function score(ByRef input_vector() As Double) As Double()
Dim var2 As Double
var2 = Math.Exp(((0) + (var0)) + (var1))
Dim var3 As Double
If (input_vector(2)) > (1.8) Then
If (input_vector(2)) > (4.8500000000000005) Then
If (inputVector(2)) > (1.8) Then
If (inputVector(2)) > (4.8500000000000005) Then
var3 = -1.1807342692411888
Else
var3 = -0.9831932134295853
Expand All @@ -33,8 +33,8 @@ Function score(ByRef input_vector() As Double) As Double()
var3 = -1.1952609652674462
End If
Dim var4 As Double
If (input_vector(2)) > (1.8) Then
If (input_vector(2)) > (4.8500000000000005) Then
If (inputVector(2)) > (1.8) Then
If (inputVector(2)) > (4.8500000000000005) Then
var4 = -0.05694282927518771
Else
var4 = 0.11960489254350348
Expand All @@ -45,28 +45,28 @@ Function score(ByRef input_vector() As Double) As Double()
Dim var5 As Double
var5 = Math.Exp(((0) + (var3)) + (var4))
Dim var6 As Double
If (input_vector(2)) > (4.8500000000000005) Then
If (input_vector(3)) > (1.9500000000000002) Then
If (inputVector(2)) > (4.8500000000000005) Then
If (inputVector(3)) > (1.9500000000000002) Then
var6 = -0.9298942558407184
Else
var6 = -0.9632815288936335
End If
Else
If (input_vector(2)) > (4.250000000000001) Then
If (inputVector(2)) > (4.250000000000001) Then
var6 = -1.1322413652523249
Else
var6 = -1.1524760761934856
End If
End If
Dim var7 As Double
If (input_vector(2)) > (4.8500000000000005) Then
If (input_vector(3)) > (1.9500000000000002) Then
If (inputVector(2)) > (4.8500000000000005) Then
If (inputVector(3)) > (1.9500000000000002) Then
var7 = 0.12809276954555665
Else
var7 = 0.09898817876916756
End If
Else
If (input_vector(2)) > (4.250000000000001) Then
If (inputVector(2)) > (4.250000000000001) Then
var7 = -0.052710589717642864
Else
var7 = -0.07292857712854424
Expand All @@ -80,6 +80,6 @@ Function score(ByRef input_vector() As Double) As Double()
var10(0) = (var2) / (var9)
var10(1) = (var5) / (var9)
var10(2) = (var8) / (var9)
score = var10
Score = var10
End Function
End Module
10 changes: 5 additions & 5 deletions generated_code_examples/visual_basic/classification/linear.vb
@@ -1,9 +1,9 @@
Module Model
Function score(ByRef input_vector() As Double) As Double()
Function Score(ByRef inputVector() As Double) As Double()
Dim var0(2) As Double
var0(0) = ((((0.2614587435880605) + ((input_vector(0)) * (0.42474116053569605))) + ((input_vector(1)) * (1.3963906033045026))) + ((input_vector(2)) * (-2.215054318516674))) + ((input_vector(3)) * (-0.9587396176450289))
var0(1) = ((((1.1348839223808307) + ((input_vector(0)) * (0.2567965976997648))) + ((input_vector(1)) * (-1.3904789369836008))) + ((input_vector(2)) * (0.596683023311173))) + ((input_vector(3)) * (-1.2690022726388828))
var0(2) = ((((-1.2162802012560197) + ((input_vector(0)) * (-1.6357766989177105))) + ((input_vector(1)) * (-1.5040638728422817))) + ((input_vector(2)) * (2.427835933129272))) + ((input_vector(3)) * (2.3469310693367276))
score = var0
var0(0) = ((((0.2614587435880605) + ((inputVector(0)) * (0.42474116053569605))) + ((inputVector(1)) * (1.3963906033045026))) + ((inputVector(2)) * (-2.215054318516674))) + ((inputVector(3)) * (-0.9587396176450289))
var0(1) = ((((1.1348839223808307) + ((inputVector(0)) * (0.2567965976997648))) + ((inputVector(1)) * (-1.3904789369836008))) + ((inputVector(2)) * (0.596683023311173))) + ((inputVector(3)) * (-1.2690022726388828))
var0(2) = ((((-1.2162802012560197) + ((inputVector(0)) * (-1.6357766989177105))) + ((inputVector(1)) * (-1.5040638728422817))) + ((inputVector(2)) * (2.427835933129272))) + ((inputVector(3)) * (2.3469310693367276))
Score = var0
End Function
End Module
Expand Up @@ -25,24 +25,24 @@ Function mulVectorNumber(ByRef v1() As Double, ByVal num As Double) As Double()

mulVectorNumber = result
End Function
Function score(ByRef input_vector() As Double) As Double()
Function Score(ByRef inputVector() As Double) As Double()
Dim var0() As Double
If (input_vector(3)) <= (0.8) Then
If (inputVector(3)) <= (0.8) Then
Dim var1(2) As Double
var1(0) = 1.0
var1(1) = 0.0
var1(2) = 0.0
var0 = var1
Else
If (input_vector(2)) <= (4.8500004) Then
If (inputVector(2)) <= (4.8500004) Then
Dim var2(2) As Double
var2(0) = 0.0
var2(1) = 0.9795918367346939
var2(2) = 0.02040816326530612
var0 = var2
Else
If (input_vector(3)) <= (1.75) Then
If (input_vector(3)) <= (1.6500001) Then
If (inputVector(3)) <= (1.75) Then
If (inputVector(3)) <= (1.6500001) Then
Dim var3(2) As Double
var3(0) = 0.0
var3(1) = 0.25
Expand All @@ -65,15 +65,15 @@ Function score(ByRef input_vector() As Double) As Double()
End If
End If
Dim var6() As Double
If (input_vector(3)) <= (0.8) Then
If (inputVector(3)) <= (0.8) Then
Dim var7(2) As Double
var7(0) = 1.0
var7(1) = 0.0
var7(2) = 0.0
var6 = var7
Else
If (input_vector(0)) <= (6.05) Then
If (input_vector(2)) <= (4.9) Then
If (inputVector(0)) <= (6.05) Then
If (inputVector(2)) <= (4.9) Then
Dim var8(2) As Double
var8(0) = 0.0
var8(1) = 0.9032258064516129
Expand All @@ -87,7 +87,7 @@ Function score(ByRef input_vector() As Double) As Double()
var6 = var9
End If
Else
If (input_vector(3)) <= (1.75) Then
If (inputVector(3)) <= (1.75) Then
Dim var10(2) As Double
var10(0) = 0.0
var10(1) = 0.8
Expand All @@ -102,6 +102,6 @@ Function score(ByRef input_vector() As Double) As Double()
End If
End If
End If
score = addVectors(mulVectorNumber(var0, 0.5), mulVectorNumber(var6, 0.5))
Score = addVectors(mulVectorNumber(var0, 0.5), mulVectorNumber(var6, 0.5))
End Function
End Module

0 comments on commit 86f8776

Please sign in to comment.