Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into str_format
- Loading branch information
Showing
35 changed files
with
562 additions
and
56 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
generated_code_examples/ruby/classification/decision_tree.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def score(input) | ||
if (input[2]) <= (2.45) | ||
var0 = [1.0, 0.0, 0.0] | ||
else | ||
if (input[3]) <= (1.75) | ||
if (input[2]) <= (4.95) | ||
if (input[3]) <= (1.6500001) | ||
var0 = [0.0, 1.0, 0.0] | ||
else | ||
var0 = [0.0, 0.0, 1.0] | ||
end | ||
else | ||
var0 = [0.0, 0.3333333333333333, 0.6666666666666666] | ||
end | ||
else | ||
var0 = [0.0, 0.021739130434782608, 0.9782608695652174] | ||
end | ||
end | ||
var0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
def score(input) | ||
if (input[2]) > (3.1500000000000004) | ||
if (input[0]) > (6.450000000000001) | ||
var0 = -1.1736122903444903 | ||
else | ||
var0 = -1.1736122903444903 | ||
end | ||
else | ||
if (input[1]) > (3.35) | ||
var0 = -0.9486122853153485 | ||
else | ||
var0 = -0.9598622855668056 | ||
end | ||
end | ||
if (input[2]) > (3.1500000000000004) | ||
if (input[2]) > (4.450000000000001) | ||
var1 = -0.07218200074594171 | ||
else | ||
var1 = -0.0725391787456957 | ||
end | ||
else | ||
if (input[1]) > (3.35) | ||
var1 = 0.130416969124648 | ||
else | ||
var1 = 0.12058330491181404 | ||
end | ||
end | ||
var2 = Math.exp(((0) + (var0)) + (var1)) | ||
if (input[2]) > (1.8) | ||
if (input[3]) > (1.6500000000000001) | ||
var3 = -1.1840003561812273 | ||
else | ||
var3 = -0.99234128317334 | ||
end | ||
else | ||
var3 = -1.1934739985732523 | ||
end | ||
if (input[3]) > (0.45000000000000007) | ||
if (input[3]) > (1.6500000000000001) | ||
var4 = -0.06203313079859976 | ||
else | ||
var4 = 0.11141505233015861 | ||
end | ||
else | ||
if (input[2]) > (1.4500000000000002) | ||
var4 = -0.0720353255122301 | ||
else | ||
var4 = -0.07164473223425313 | ||
end | ||
end | ||
var5 = Math.exp(((0) + (var3)) + (var4)) | ||
if (input[3]) > (1.6500000000000001) | ||
if (input[2]) > (5.3500000000000005) | ||
var6 = -0.9314095846701695 | ||
else | ||
var6 = -0.9536869036452162 | ||
end | ||
else | ||
if (input[2]) > (4.450000000000001) | ||
var6 = -1.115439610985773 | ||
else | ||
var6 = -1.1541827744206368 | ||
end | ||
end | ||
if (input[2]) > (4.750000000000001) | ||
if (input[2]) > (5.150000000000001) | ||
var7 = 0.12968922424213622 | ||
else | ||
var7 = 0.07468384042736965 | ||
end | ||
else | ||
if (input[1]) > (2.7500000000000004) | ||
var7 = -0.07311533184609437 | ||
else | ||
var7 = -0.06204412771870974 | ||
end | ||
end | ||
var8 = Math.exp(((0) + (var6)) + (var7)) | ||
var9 = ((var2) + (var5)) + (var8) | ||
[(var2).fdiv(var9), (var5).fdiv(var9), (var8).fdiv(var9)] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def score(input) | ||
[((((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))] | ||
end |
43 changes: 43 additions & 0 deletions
43
generated_code_examples/ruby/classification/random_forest.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
def add_vectors(v1, v2) | ||
v1.zip(v2).map { |x, y| x + y } | ||
end | ||
def mul_vector_number(v1, num) | ||
v1.map { |i| i * num } | ||
end | ||
def score(input) | ||
if (input[3]) <= (0.8) | ||
var0 = [1.0, 0.0, 0.0] | ||
else | ||
if (input[2]) <= (4.8500004) | ||
var0 = [0.0, 0.9622641509433962, 0.03773584905660377] | ||
else | ||
if (input[3]) <= (1.75) | ||
if (input[3]) <= (1.6500001) | ||
var0 = [0.0, 0.25, 0.75] | ||
else | ||
var0 = [0.0, 1.0, 0.0] | ||
end | ||
else | ||
var0 = [0.0, 0.0, 1.0] | ||
end | ||
end | ||
end | ||
if (input[3]) <= (0.8) | ||
var1 = [1.0, 0.0, 0.0] | ||
else | ||
if (input[0]) <= (6.1499996) | ||
if (input[2]) <= (4.8500004) | ||
var1 = [0.0, 0.9090909090909091, 0.09090909090909091] | ||
else | ||
var1 = [0.0, 0.0, 1.0] | ||
end | ||
else | ||
if (input[3]) <= (1.75) | ||
var1 = [0.0, 0.8666666666666667, 0.13333333333333333] | ||
else | ||
var1 = [0.0, 0.0, 1.0] | ||
end | ||
end | ||
end | ||
mul_vector_number(add_vectors(var0, var1), 0.5) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
def score(input) | ||
var0 = (0) - (0.06408191572099702) | ||
var1 = Math.exp((var0) * ((((((5.6) - (input[0])) ** (2)) + (((2.9) - (input[1])) ** (2))) + (((3.6) - (input[2])) ** (2))) + (((1.3) - (input[3])) ** (2)))) | ||
var2 = Math.exp((var0) * ((((((5.4) - (input[0])) ** (2)) + (((3.0) - (input[1])) ** (2))) + (((4.5) - (input[2])) ** (2))) + (((1.5) - (input[3])) ** (2)))) | ||
var3 = Math.exp((var0) * ((((((6.2) - (input[0])) ** (2)) + (((2.2) - (input[1])) ** (2))) + (((4.5) - (input[2])) ** (2))) + (((1.5) - (input[3])) ** (2)))) | ||
var4 = Math.exp((var0) * ((((((5.0) - (input[0])) ** (2)) + (((2.3) - (input[1])) ** (2))) + (((3.3) - (input[2])) ** (2))) + (((1.0) - (input[3])) ** (2)))) | ||
var5 = Math.exp((var0) * ((((((5.9) - (input[0])) ** (2)) + (((3.2) - (input[1])) ** (2))) + (((4.8) - (input[2])) ** (2))) + (((1.8) - (input[3])) ** (2)))) | ||
var6 = Math.exp((var0) * ((((((6.7) - (input[0])) ** (2)) + (((3.0) - (input[1])) ** (2))) + (((5.0) - (input[2])) ** (2))) + (((1.7) - (input[3])) ** (2)))) | ||
var7 = Math.exp((var0) * ((((((4.9) - (input[0])) ** (2)) + (((2.4) - (input[1])) ** (2))) + (((3.3) - (input[2])) ** (2))) + (((1.0) - (input[3])) ** (2)))) | ||
var8 = Math.exp((var0) * ((((((6.3) - (input[0])) ** (2)) + (((2.5) - (input[1])) ** (2))) + (((4.9) - (input[2])) ** (2))) + (((1.5) - (input[3])) ** (2)))) | ||
var9 = Math.exp((var0) * ((((((6.0) - (input[0])) ** (2)) + (((2.7) - (input[1])) ** (2))) + (((5.1) - (input[2])) ** (2))) + (((1.6) - (input[3])) ** (2)))) | ||
var10 = Math.exp((var0) * ((((((5.7) - (input[0])) ** (2)) + (((2.6) - (input[1])) ** (2))) + (((3.5) - (input[2])) ** (2))) + (((1.0) - (input[3])) ** (2)))) | ||
var11 = Math.exp((var0) * ((((((5.1) - (input[0])) ** (2)) + (((2.5) - (input[1])) ** (2))) + (((3.0) - (input[2])) ** (2))) + (((1.1) - (input[3])) ** (2)))) | ||
var12 = Math.exp((var0) * ((((((5.1) - (input[0])) ** (2)) + (((3.8) - (input[1])) ** (2))) + (((1.9) - (input[2])) ** (2))) + (((0.4) - (input[3])) ** (2)))) | ||
var13 = Math.exp((var0) * ((((((5.7) - (input[0])) ** (2)) + (((4.4) - (input[1])) ** (2))) + (((1.5) - (input[2])) ** (2))) + (((0.4) - (input[3])) ** (2)))) | ||
var14 = Math.exp((var0) * ((((((5.1) - (input[0])) ** (2)) + (((3.3) - (input[1])) ** (2))) + (((1.7) - (input[2])) ** (2))) + (((0.5) - (input[3])) ** (2)))) | ||
var15 = Math.exp((var0) * ((((((5.7) - (input[0])) ** (2)) + (((3.8) - (input[1])) ** (2))) + (((1.7) - (input[2])) ** (2))) + (((0.3) - (input[3])) ** (2)))) | ||
var16 = Math.exp((var0) * ((((((5.4) - (input[0])) ** (2)) + (((3.4) - (input[1])) ** (2))) + (((1.7) - (input[2])) ** (2))) + (((0.2) - (input[3])) ** (2)))) | ||
var17 = Math.exp((var0) * ((((((5.0) - (input[0])) ** (2)) + (((3.0) - (input[1])) ** (2))) + (((1.6) - (input[2])) ** (2))) + (((0.2) - (input[3])) ** (2)))) | ||
var18 = Math.exp((var0) * ((((((4.5) - (input[0])) ** (2)) + (((2.3) - (input[1])) ** (2))) + (((1.3) - (input[2])) ** (2))) + (((0.3) - (input[3])) ** (2)))) | ||
var19 = Math.exp((var0) * ((((((4.8) - (input[0])) ** (2)) + (((3.4) - (input[1])) ** (2))) + (((1.9) - (input[2])) ** (2))) + (((0.2) - (input[3])) ** (2)))) | ||
var20 = Math.exp((var0) * ((((((6.0) - (input[0])) ** (2)) + (((3.0) - (input[1])) ** (2))) + (((4.8) - (input[2])) ** (2))) + (((1.8) - (input[3])) ** (2)))) | ||
var21 = Math.exp((var0) * ((((((6.3) - (input[0])) ** (2)) + (((2.8) - (input[1])) ** (2))) + (((5.1) - (input[2])) ** (2))) + (((1.5) - (input[3])) ** (2)))) | ||
var22 = Math.exp((var0) * ((((((6.1) - (input[0])) ** (2)) + (((3.0) - (input[1])) ** (2))) + (((4.9) - (input[2])) ** (2))) + (((1.8) - (input[3])) ** (2)))) | ||
var23 = Math.exp((var0) * ((((((4.9) - (input[0])) ** (2)) + (((2.5) - (input[1])) ** (2))) + (((4.5) - (input[2])) ** (2))) + (((1.7) - (input[3])) ** (2)))) | ||
var24 = Math.exp((var0) * ((((((5.6) - (input[0])) ** (2)) + (((2.8) - (input[1])) ** (2))) + (((4.9) - (input[2])) ** (2))) + (((2.0) - (input[3])) ** (2)))) | ||
var25 = Math.exp((var0) * ((((((6.0) - (input[0])) ** (2)) + (((2.2) - (input[1])) ** (2))) + (((5.0) - (input[2])) ** (2))) + (((1.5) - (input[3])) ** (2)))) | ||
var26 = Math.exp((var0) * ((((((7.9) - (input[0])) ** (2)) + (((3.8) - (input[1])) ** (2))) + (((6.4) - (input[2])) ** (2))) + (((2.0) - (input[3])) ** (2)))) | ||
var27 = Math.exp((var0) * ((((((7.2) - (input[0])) ** (2)) + (((3.0) - (input[1])) ** (2))) + (((5.8) - (input[2])) ** (2))) + (((1.6) - (input[3])) ** (2)))) | ||
var28 = Math.exp((var0) * ((((((6.2) - (input[0])) ** (2)) + (((2.8) - (input[1])) ** (2))) + (((4.8) - (input[2])) ** (2))) + (((1.8) - (input[3])) ** (2)))) | ||
[(((((((((((((((((((0.11166728251449935) + ((var1) * (-0.7546041223284677))) + ((var2) * (-0.0))) + ((var3) * (-0.0))) + ((var4) * (-0.8877695556805599))) + ((var5) * (-0.0))) + ((var6) * (-0.0))) + ((var7) * (-0.8877695556805599))) + ((var8) * (-0.0))) + ((var9) * (-0.0))) + ((var10) * (-0.8877695556805599))) + ((var11) * (-0.8877695556805599))) + ((var12) * (0.8877695556805599))) + ((var13) * (0.0))) + ((var14) * (0.8877695556805599))) + ((var15) * (0.0))) + ((var16) * (0.7126145313390118))) + ((var17) * (0.04198959098945601))) + ((var18) * (0.8877695556805599))) + ((var19) * (0.8877695556805599)), (((((((((((((((((-0.043064448593694335) + ((var20) * (-0.3790553204589494))) + ((var21) * (-0.0))) + ((var22) * (-0.0))) + ((var23) * (-0.3790553204589494))) + ((var24) * (-0.3730604955455548))) + ((var25) * (-0.09964456068725433))) + ((var26) * (-0.26645281866213855))) + ((var27) * (-0.0))) + ((var28) * (-0.3790553204589494))) + ((var12) * (0.3790553204589494))) + ((var13) * (0.05589866243098008))) + ((var14) * (0.3790553204589494))) + ((var15) * (0.3790553204589494))) + ((var16) * (0.0))) + ((var17) * (0.0))) + ((var18) * (0.30420389200501824))) + ((var19) * (0.3790553204589494)), ((((((((((((((((((((2.1222908467070423) + ((var20) * (-109.16681524774745))) + ((var21) * (-109.16681524774745))) + ((var22) * (-105.17803142414256))) + ((var23) * (-17.487321182626303))) + ((var24) * (-0.0))) + ((var25) * (-71.97838649684462))) + ((var26) * (-0.0))) + ((var27) * (-12.773209867105617))) + ((var28) * (-109.16681524774745))) + ((var1) * (0.0))) + ((var2) * (56.65430288285653))) + ((var3) * (41.59583084011515))) + ((var4) * (0.0))) + ((var5) * (109.16681524774745))) + ((var6) * (109.16681524774745))) + ((var7) * (0.0))) + ((var8) * (109.16681524774745))) + ((var9) * (109.16681524774745))) + ((var10) * (0.0))) + ((var11) * (0.0))] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
def score(input) | ||
if (input[2]) >= (2.45) | ||
var0 = -0.219950154 | ||
else | ||
var0 = 0.430243909 | ||
end | ||
if (input[2]) >= (2.45) | ||
var1 = -0.196918547 | ||
else | ||
var1 = 0.294934332 | ||
end | ||
var2 = Math.exp(((0.5) + (var0)) + (var1)) | ||
if (input[2]) >= (2.45) | ||
if (input[3]) >= (1.75) | ||
var3 = -0.200518161 | ||
else | ||
var3 = 0.369124442 | ||
end | ||
else | ||
var3 = -0.215121984 | ||
end | ||
if (input[2]) >= (2.45) | ||
if (input[2]) >= (4.8500004) | ||
var4 = -0.148884818 | ||
else | ||
var4 = 0.279661298 | ||
end | ||
else | ||
var4 = -0.191438049 | ||
end | ||
var5 = Math.exp(((0.5) + (var3)) + (var4)) | ||
if (input[3]) >= (1.6500001) | ||
var6 = 0.402985066 | ||
else | ||
if (input[2]) >= (4.95) | ||
var6 = 0.217241377 | ||
else | ||
var6 = -0.219740286 | ||
end | ||
end | ||
if (input[2]) >= (4.75) | ||
if (input[3]) >= (1.75) | ||
var7 = 0.286929518 | ||
else | ||
var7 = 0.0627289712 | ||
end | ||
else | ||
if (input[3]) >= (1.55) | ||
var7 = 0.00989914499 | ||
else | ||
var7 = -0.196593687 | ||
end | ||
end | ||
var8 = Math.exp(((0.5) + (var6)) + (var7)) | ||
var9 = ((var2) + (var5)) + (var8) | ||
[(var2).fdiv(var9), (var5).fdiv(var9), (var8).fdiv(var9)] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def score(input) | ||
if (input[5]) <= (6.941) | ||
if (input[12]) <= (14.4) | ||
if (input[7]) <= (1.38485) | ||
var0 = 45.58 | ||
else | ||
var0 = 22.939004149377574 | ||
end | ||
else | ||
var0 = 14.910404624277467 | ||
end | ||
else | ||
if (input[5]) <= (7.4370003) | ||
var0 = 32.11304347826088 | ||
else | ||
var0 = 45.096666666666664 | ||
end | ||
end | ||
var0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def score(input) | ||
if (input[5]) > (6.918000000000001) | ||
if (input[5]) > (7.437) | ||
var0 = 24.81112131071211 | ||
else | ||
var0 = 23.5010290754961 | ||
end | ||
else | ||
if (input[12]) > (14.365) | ||
var0 = 21.796569516771488 | ||
else | ||
var0 = 22.640634908349323 | ||
end | ||
end | ||
if (input[12]) > (9.63) | ||
if (input[12]) > (19.23) | ||
var1 = -0.9218520876020193 | ||
else | ||
var1 = -0.30490175606373926 | ||
end | ||
else | ||
if (input[5]) > (7.437) | ||
var1 = 2.028554553190867 | ||
else | ||
var1 = 0.45970642160364367 | ||
end | ||
end | ||
((0) + (var0)) + (var1) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def score(input) | ||
(((((((((((((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)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
def score(input) | ||
if (input[12]) <= (8.91) | ||
if (input[5]) <= (6.902) | ||
if (input[7]) <= (1.48495) | ||
var0 = 50.0 | ||
else | ||
var0 = 25.320000000000004 | ||
end | ||
else | ||
var0 = 38.34810126582279 | ||
end | ||
else | ||
if (input[0]) <= (5.84803) | ||
var0 = 19.99185520361991 | ||
else | ||
var0 = 12.102469135802467 | ||
end | ||
end | ||
if (input[12]) <= (9.725) | ||
if (input[5]) <= (7.4525) | ||
if (input[5]) <= (6.7539997) | ||
var1 = 24.801739130434775 | ||
else | ||
var1 = 32.47230769230769 | ||
end | ||
else | ||
var1 = 47.075 | ||
end | ||
else | ||
if (input[12]) <= (15.0) | ||
var1 = 20.44094488188976 | ||
else | ||
var1 = 14.823214285714291 | ||
end | ||
end | ||
((var0) + (var1)) * (0.5) | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def score(input) | ||
if (input[12]) >= (9.725) | ||
if (input[12]) >= (16.085) | ||
var0 = 4.09124994 | ||
else | ||
var0 = 5.89006901 | ||
end | ||
else | ||
if (input[5]) >= (6.941) | ||
var0 = 11.241127 | ||
else | ||
var0 = 7.45130444 | ||
end | ||
end | ||
if (input[12]) >= (5.1549997) | ||
if (input[12]) >= (14.4) | ||
var1 = 3.00165963 | ||
else | ||
var1 = 4.8301239 | ||
end | ||
else | ||
if (input[5]) >= (7.406) | ||
var1 = 9.98775578 | ||
else | ||
var1 = 6.78264093 | ||
end | ||
end | ||
((0.5) + (var0)) + (var1) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.