Skip to content

Commit

Permalink
Merge branch 'master' into floats_improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
StrikerRUS committed Aug 4, 2020
2 parents 8f272bc + eef38e7 commit 87ee455
Show file tree
Hide file tree
Showing 24 changed files with 486 additions and 174 deletions.
1 change: 0 additions & 1 deletion README.md
@@ -1,6 +1,5 @@
# m2cgen

[![Travis Status](https://travis-ci.org/BayesWitnesses/m2cgen.svg?branch=master)](https://travis-ci.org/BayesWitnesses/m2cgen)
[![GitHub Actions Status](https://github.com/BayesWitnesses/m2cgen/workflows/GitHub%20Actions/badge.svg?branch=master)](https://github.com/BayesWitnesses/m2cgen/actions)
[![Coverage Status](https://coveralls.io/repos/github/BayesWitnesses/m2cgen/badge.svg?branch=master)](https://coveralls.io/github/BayesWitnesses/m2cgen?branch=master)
[![License: MIT](https://img.shields.io/github/license/BayesWitnesses/m2cgen.svg)](https://github.com/BayesWitnesses/m2cgen/blob/master/LICENSE)
Expand Down
16 changes: 16 additions & 0 deletions generated_code_examples/f_sharp/classification/decision_tree.fs
@@ -0,0 +1,16 @@
let score (input : double list) =
let func0 =
if ((input.[2]) <= (2.45)) then
[1.0; 0.0; 0.0]
else
if ((input.[3]) <= (1.75)) then
if ((input.[2]) <= (4.95)) then
if ((input.[3]) <= (1.6500001)) then
[0.0; 1.0; 0.0]
else
[0.0; 0.0; 1.0]
else
[0.0; 0.3333333333333333; 0.6666666666666666]
else
[0.0; 0.021739130434782608; 0.9782608695652174]
func0
70 changes: 70 additions & 0 deletions generated_code_examples/f_sharp/classification/lightgbm.fs
@@ -0,0 +1,70 @@
let score (input : double list) =
let func0 =
if ((input.[2]) > (3.1500000000000004)) then
-1.1736122903444903
else
if ((input.[1]) > (3.35)) then
-0.9486122853153485
else
-0.9598622855668056
let func1 =
if ((input.[2]) > (3.1500000000000004)) then
if ((input.[2]) > (4.450000000000001)) then
-0.07218200074594171
else
-0.0725391787456957
else
if ((input.[1]) > (3.35)) then
0.130416969124648
else
0.12058330491181404
let func2 =
exp ((func0) + (func1))
let func3 =
if ((input.[2]) > (1.8)) then
if ((input.[3]) > (1.6500000000000001)) then
-1.1840003561812273
else
-0.99234128317334
else
-1.1934739985732523
let func4 =
if ((input.[3]) > (0.45000000000000007)) then
if ((input.[3]) > (1.6500000000000001)) then
-0.06203313079859976
else
0.11141505233015861
else
if ((input.[2]) > (1.4500000000000002)) then
-0.0720353255122301
else
-0.07164473223425313
let func5 =
exp ((func3) + (func4))
let func6 =
if ((input.[3]) > (1.6500000000000001)) then
if ((input.[2]) > (5.3500000000000005)) then
-0.9314095846701695
else
-0.9536869036452162
else
if ((input.[2]) > (4.450000000000001)) then
-1.115439610985773
else
-1.1541827744206368
let func7 =
if ((input.[2]) > (4.750000000000001)) then
if ((input.[2]) > (5.150000000000001)) then
0.12968922424213622
else
0.07468384042736965
else
if ((input.[1]) > (2.7500000000000004)) then
-0.07311533184609437
else
-0.06204412771870974
let func8 =
exp ((func6) + (func7))
let func9 =
((func2) + (func5)) + (func8)
[(func2) / (func9); (func5) / (func9); (func8) / (func9)]
2 changes: 2 additions & 0 deletions generated_code_examples/f_sharp/classification/linear.fs
@@ -0,0 +1,2 @@
let score (input : double list) =
[((((9.774126241420623) + ((input.[0]) * (-0.41545978008486634))) + ((input.[1]) * (0.9619661444337051))) + ((input.[2]) * (-2.5028461157608604))) + ((input.[3]) * (-1.0766107732916166)); ((((2.248771246116064) + ((input.[0]) * (0.5239098915475155))) + ((input.[1]) * (-0.3177027667958222))) + ((input.[2]) * (-0.20333498652290763))) + ((input.[3]) * (-0.9399605394445277)); ((((-12.022897487538232) + ((input.[0]) * (-0.10845011146263966))) + ((input.[1]) * (-0.6442633776378855))) + ((input.[2]) * (2.7061811022837774))) + ((input.[3]) * (2.01657131273614))]
32 changes: 32 additions & 0 deletions generated_code_examples/f_sharp/classification/random_forest.fs
@@ -0,0 +1,32 @@
let private addVectors v1 v2 = List.map2 (+) v1 v2
let private mulVectorNumber v1 num = List.map (fun i -> i * num) v1
let score (input : double list) =
let func0 =
if ((input.[3]) <= (0.8)) then
[1.0; 0.0; 0.0]
else
if ((input.[2]) <= (4.8500004)) then
[0.0; 0.9622641509433962; 0.03773584905660377]
else
if ((input.[3]) <= (1.75)) then
if ((input.[3]) <= (1.6500001)) then
[0.0; 0.25; 0.75]
else
[0.0; 1.0; 0.0]
else
[0.0; 0.0; 1.0]
let func1 =
if ((input.[3]) <= (0.8)) then
[1.0; 0.0; 0.0]
else
if ((input.[0]) <= (6.1499996)) then
if ((input.[2]) <= (4.8500004)) then
[0.0; 0.9090909090909091; 0.09090909090909091]
else
[0.0; 0.0; 1.0]
else
if ((input.[3]) <= (1.75)) then
[0.0; 0.8666666666666667; 0.13333333333333333]
else
[0.0; 0.0; 1.0]
mulVectorNumber (addVectors (func0) (func1)) (0.5)
58 changes: 58 additions & 0 deletions generated_code_examples/f_sharp/classification/svm.fs
@@ -0,0 +1,58 @@
let score (input : double list) =
let func0 =
exp ((-0.06408191572099702) * ((((((5.6) - (input.[0])) ** (2.0)) + (((2.9) - (input.[1])) ** (2.0))) + (((3.6) - (input.[2])) ** (2.0))) + (((1.3) - (input.[3])) ** (2.0))))
let func1 =
exp ((-0.06408191572099702) * ((((((5.4) - (input.[0])) ** (2.0)) + (((3.0) - (input.[1])) ** (2.0))) + (((4.5) - (input.[2])) ** (2.0))) + (((1.5) - (input.[3])) ** (2.0))))
let func2 =
exp ((-0.06408191572099702) * ((((((6.2) - (input.[0])) ** (2.0)) + (((2.2) - (input.[1])) ** (2.0))) + (((4.5) - (input.[2])) ** (2.0))) + (((1.5) - (input.[3])) ** (2.0))))
let func3 =
exp ((-0.06408191572099702) * ((((((5.0) - (input.[0])) ** (2.0)) + (((2.3) - (input.[1])) ** (2.0))) + (((3.3) - (input.[2])) ** (2.0))) + (((1.0) - (input.[3])) ** (2.0))))
let func4 =
exp ((-0.06408191572099702) * ((((((5.9) - (input.[0])) ** (2.0)) + (((3.2) - (input.[1])) ** (2.0))) + (((4.8) - (input.[2])) ** (2.0))) + (((1.8) - (input.[3])) ** (2.0))))
let func5 =
exp ((-0.06408191572099702) * ((((((6.7) - (input.[0])) ** (2.0)) + (((3.0) - (input.[1])) ** (2.0))) + (((5.0) - (input.[2])) ** (2.0))) + (((1.7) - (input.[3])) ** (2.0))))
let func6 =
exp ((-0.06408191572099702) * ((((((4.9) - (input.[0])) ** (2.0)) + (((2.4) - (input.[1])) ** (2.0))) + (((3.3) - (input.[2])) ** (2.0))) + (((1.0) - (input.[3])) ** (2.0))))
let func7 =
exp ((-0.06408191572099702) * ((((((6.3) - (input.[0])) ** (2.0)) + (((2.5) - (input.[1])) ** (2.0))) + (((4.9) - (input.[2])) ** (2.0))) + (((1.5) - (input.[3])) ** (2.0))))
let func8 =
exp ((-0.06408191572099702) * ((((((6.0) - (input.[0])) ** (2.0)) + (((2.7) - (input.[1])) ** (2.0))) + (((5.1) - (input.[2])) ** (2.0))) + (((1.6) - (input.[3])) ** (2.0))))
let func9 =
exp ((-0.06408191572099702) * ((((((5.7) - (input.[0])) ** (2.0)) + (((2.6) - (input.[1])) ** (2.0))) + (((3.5) - (input.[2])) ** (2.0))) + (((1.0) - (input.[3])) ** (2.0))))
let func10 =
exp ((-0.06408191572099702) * ((((((5.1) - (input.[0])) ** (2.0)) + (((2.5) - (input.[1])) ** (2.0))) + (((3.0) - (input.[2])) ** (2.0))) + (((1.1) - (input.[3])) ** (2.0))))
let func11 =
exp ((-0.06408191572099702) * ((((((5.1) - (input.[0])) ** (2.0)) + (((3.8) - (input.[1])) ** (2.0))) + (((1.9) - (input.[2])) ** (2.0))) + (((0.4) - (input.[3])) ** (2.0))))
let func12 =
exp ((-0.06408191572099702) * ((((((5.7) - (input.[0])) ** (2.0)) + (((4.4) - (input.[1])) ** (2.0))) + (((1.5) - (input.[2])) ** (2.0))) + (((0.4) - (input.[3])) ** (2.0))))
let func13 =
exp ((-0.06408191572099702) * ((((((5.1) - (input.[0])) ** (2.0)) + (((3.3) - (input.[1])) ** (2.0))) + (((1.7) - (input.[2])) ** (2.0))) + (((0.5) - (input.[3])) ** (2.0))))
let func14 =
exp ((-0.06408191572099702) * ((((((5.7) - (input.[0])) ** (2.0)) + (((3.8) - (input.[1])) ** (2.0))) + (((1.7) - (input.[2])) ** (2.0))) + (((0.3) - (input.[3])) ** (2.0))))
let func15 =
exp ((-0.06408191572099702) * ((((((5.4) - (input.[0])) ** (2.0)) + (((3.4) - (input.[1])) ** (2.0))) + (((1.7) - (input.[2])) ** (2.0))) + (((0.2) - (input.[3])) ** (2.0))))
let func16 =
exp ((-0.06408191572099702) * ((((((5.0) - (input.[0])) ** (2.0)) + (((3.0) - (input.[1])) ** (2.0))) + (((1.6) - (input.[2])) ** (2.0))) + (((0.2) - (input.[3])) ** (2.0))))
let func17 =
exp ((-0.06408191572099702) * ((((((4.5) - (input.[0])) ** (2.0)) + (((2.3) - (input.[1])) ** (2.0))) + (((1.3) - (input.[2])) ** (2.0))) + (((0.3) - (input.[3])) ** (2.0))))
let func18 =
exp ((-0.06408191572099702) * ((((((4.8) - (input.[0])) ** (2.0)) + (((3.4) - (input.[1])) ** (2.0))) + (((1.9) - (input.[2])) ** (2.0))) + (((0.2) - (input.[3])) ** (2.0))))
let func19 =
exp ((-0.06408191572099702) * ((((((6.0) - (input.[0])) ** (2.0)) + (((3.0) - (input.[1])) ** (2.0))) + (((4.8) - (input.[2])) ** (2.0))) + (((1.8) - (input.[3])) ** (2.0))))
let func20 =
exp ((-0.06408191572099702) * ((((((6.3) - (input.[0])) ** (2.0)) + (((2.8) - (input.[1])) ** (2.0))) + (((5.1) - (input.[2])) ** (2.0))) + (((1.5) - (input.[3])) ** (2.0))))
let func21 =
exp ((-0.06408191572099702) * ((((((6.1) - (input.[0])) ** (2.0)) + (((3.0) - (input.[1])) ** (2.0))) + (((4.9) - (input.[2])) ** (2.0))) + (((1.8) - (input.[3])) ** (2.0))))
let func22 =
exp ((-0.06408191572099702) * ((((((4.9) - (input.[0])) ** (2.0)) + (((2.5) - (input.[1])) ** (2.0))) + (((4.5) - (input.[2])) ** (2.0))) + (((1.7) - (input.[3])) ** (2.0))))
let func23 =
exp ((-0.06408191572099702) * ((((((5.6) - (input.[0])) ** (2.0)) + (((2.8) - (input.[1])) ** (2.0))) + (((4.9) - (input.[2])) ** (2.0))) + (((2.0) - (input.[3])) ** (2.0))))
let func24 =
exp ((-0.06408191572099702) * ((((((6.0) - (input.[0])) ** (2.0)) + (((2.2) - (input.[1])) ** (2.0))) + (((5.0) - (input.[2])) ** (2.0))) + (((1.5) - (input.[3])) ** (2.0))))
let func25 =
exp ((-0.06408191572099702) * ((((((7.9) - (input.[0])) ** (2.0)) + (((3.8) - (input.[1])) ** (2.0))) + (((6.4) - (input.[2])) ** (2.0))) + (((2.0) - (input.[3])) ** (2.0))))
let func26 =
exp ((-0.06408191572099702) * ((((((7.2) - (input.[0])) ** (2.0)) + (((3.0) - (input.[1])) ** (2.0))) + (((5.8) - (input.[2])) ** (2.0))) + (((1.6) - (input.[3])) ** (2.0))))
let func27 =
exp ((-0.06408191572099702) * ((((((6.2) - (input.[0])) ** (2.0)) + (((2.8) - (input.[1])) ** (2.0))) + (((4.8) - (input.[2])) ** (2.0))) + (((1.8) - (input.[3])) ** (2.0))))
[(((((((((((((((((((0.11166728251449935) + ((func0) * (-0.7546041223284677))) + ((func1) * (-0.0))) + ((func2) * (-0.0))) + ((func3) * (-0.8877695556805599))) + ((func4) * (-0.0))) + ((func5) * (-0.0))) + ((func6) * (-0.8877695556805599))) + ((func7) * (-0.0))) + ((func8) * (-0.0))) + ((func9) * (-0.8877695556805599))) + ((func10) * (-0.8877695556805599))) + ((func11) * (0.8877695556805599))) + ((func12) * (0.0))) + ((func13) * (0.8877695556805599))) + ((func14) * (0.0))) + ((func15) * (0.7126145313390118))) + ((func16) * (0.04198959098945601))) + ((func17) * (0.8877695556805599))) + ((func18) * (0.8877695556805599)); (((((((((((((((((-0.043064448593694335) + ((func19) * (-0.3790553204589494))) + ((func20) * (-0.0))) + ((func21) * (-0.0))) + ((func22) * (-0.3790553204589494))) + ((func23) * (-0.3730604955455548))) + ((func24) * (-0.09964456068725433))) + ((func25) * (-0.26645281866213855))) + ((func26) * (-0.0))) + ((func27) * (-0.3790553204589494))) + ((func11) * (0.3790553204589494))) + ((func12) * (0.05589866243098008))) + ((func13) * (0.3790553204589494))) + ((func14) * (0.3790553204589494))) + ((func15) * (0.0))) + ((func16) * (0.0))) + ((func17) * (0.30420389200501824))) + ((func18) * (0.3790553204589494)); ((((((((((((((((((((2.1222908467070423) + ((func19) * (-109.16681524774745))) + ((func20) * (-109.16681524774745))) + ((func21) * (-105.17803142414256))) + ((func22) * (-17.487321182626303))) + ((func23) * (-0.0))) + ((func24) * (-71.97838649684462))) + ((func25) * (-0.0))) + ((func26) * (-12.773209867105617))) + ((func27) * (-109.16681524774745))) + ((func0) * (0.0))) + ((func1) * (56.65430288285653))) + ((func2) * (41.59583084011515))) + ((func3) * (0.0))) + ((func4) * (109.16681524774745))) + ((func5) * (109.16681524774745))) + ((func6) * (0.0))) + ((func7) * (109.16681524774745))) + ((func8) * (109.16681524774745))) + ((func9) * (0.0))) + ((func10) * (0.0))]
55 changes: 55 additions & 0 deletions generated_code_examples/f_sharp/classification/xgboost.fs
@@ -0,0 +1,55 @@
let score (input : double list) =
let func0 =
if ((input.[2]) >= (2.45)) then
-0.219950154
else
0.430243909
let func1 =
if ((input.[2]) >= (2.45)) then
-0.196918547
else
0.294934332
let func2 =
exp ((0.5) + ((func0) + (func1)))
let func3 =
if ((input.[2]) >= (2.45)) then
if ((input.[3]) >= (1.75)) then
-0.200518161
else
0.369124442
else
-0.215121984
let func4 =
if ((input.[2]) >= (2.45)) then
if ((input.[2]) >= (4.8500004)) then
-0.148884818
else
0.279661298
else
-0.191438049
let func5 =
exp ((0.5) + ((func3) + (func4)))
let func6 =
if ((input.[3]) >= (1.6500001)) then
0.402985066
else
if ((input.[2]) >= (4.95)) then
0.217241377
else
-0.219740286
let func7 =
if ((input.[2]) >= (4.75)) then
if ((input.[3]) >= (1.75)) then
0.286929518
else
0.0627289712
else
if ((input.[3]) >= (1.55)) then
0.00989914499
else
-0.196593687
let func8 =
exp ((0.5) + ((func6) + (func7)))
let func9 =
((func2) + (func5)) + (func8)
[(func2) / (func9); (func5) / (func9); (func8) / (func9)]
16 changes: 16 additions & 0 deletions generated_code_examples/f_sharp/regression/decision_tree.fs
@@ -0,0 +1,16 @@
let score (input : double list) =
let func0 =
if ((input.[5]) <= (6.941)) then
if ((input.[12]) <= (14.4)) then
if ((input.[7]) <= (1.38485)) then
45.58
else
22.939004149377574
else
14.910404624277467
else
if ((input.[5]) <= (7.4370003)) then
32.11304347826088
else
45.096666666666664
func0
24 changes: 24 additions & 0 deletions generated_code_examples/f_sharp/regression/lightgbm.fs
@@ -0,0 +1,24 @@
let score (input : double list) =
let func0 =
if ((input.[5]) > (6.918000000000001)) then
if ((input.[5]) > (7.437)) then
24.81112131071211
else
23.5010290754961
else
if ((input.[12]) > (14.365)) then
21.796569516771488
else
22.640634908349323
let func1 =
if ((input.[12]) > (9.63)) then
if ((input.[12]) > (19.23)) then
-0.9218520876020193
else
-0.30490175606373926
else
if ((input.[5]) > (7.437)) then
2.028554553190867
else
0.45970642160364367
(func0) + (func1)
2 changes: 2 additions & 0 deletions generated_code_examples/f_sharp/regression/linear.fs
@@ -0,0 +1,2 @@
let score (input : double list) =
(((((((((((((37.13534685269026) + ((input.[0]) * (-0.10859102499053891))) + ((input.[1]) * (0.04419889872599562))) + ((input.[2]) * (0.017466905407308372))) + ((input.[3]) * (2.832321087004625))) + ((input.[4]) * (-18.48374869795793))) + ((input.[5]) * (3.835495548436564))) + ((input.[6]) * (0.00014091650900214126))) + ((input.[7]) * (-1.5040340046693192))) + ((input.[8]) * (0.31061748524339455))) + ((input.[9]) * (-0.012306650033752073))) + ((input.[10]) * (-0.9736183984588207))) + ((input.[11]) * (0.009403964809694718))) + ((input.[12]) * (-0.5203427347180726))
30 changes: 30 additions & 0 deletions generated_code_examples/f_sharp/regression/random_forest.fs
@@ -0,0 +1,30 @@
let score (input : double list) =
let func0 =
if ((input.[12]) <= (8.91)) then
if ((input.[5]) <= (6.902)) then
if ((input.[7]) <= (1.48495)) then
50.0
else
25.320000000000004
else
38.34810126582279
else
if ((input.[0]) <= (5.84803)) then
19.99185520361991
else
12.102469135802467
let func1 =
if ((input.[12]) <= (9.725)) then
if ((input.[5]) <= (7.4525)) then
if ((input.[5]) <= (6.7539997)) then
24.801739130434775
else
32.47230769230769
else
47.075
else
if ((input.[12]) <= (15.0)) then
20.44094488188976
else
14.823214285714291
((func0) + (func1)) * (0.5)
2 changes: 2 additions & 0 deletions generated_code_examples/f_sharp/regression/svm.fs

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions generated_code_examples/f_sharp/regression/xgboost.fs
@@ -0,0 +1,24 @@
let score (input : double list) =
let func0 =
if ((input.[12]) >= (9.725)) then
if ((input.[12]) >= (16.085)) then
4.09124994
else
5.89006901
else
if ((input.[5]) >= (6.941)) then
11.241127
else
7.45130444
let func1 =
if ((input.[12]) >= (5.1549997)) then
if ((input.[12]) >= (14.4)) then
3.00165963
else
4.8301239
else
if ((input.[5]) >= (7.406)) then
9.98775578
else
6.78264093
(0.5) + ((func0) + (func1))

0 comments on commit 87ee455

Please sign in to comment.