Skip to content

Commit

Permalink
chore(stdlib): convert bayes to acc tests (#4821)
Browse files Browse the repository at this point in the history
  • Loading branch information
OfTheDelmer authored Jun 3, 2022
1 parent 167cfbf commit a0b00f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1,337 deletions.
2 changes: 1 addition & 1 deletion libflux/go/libflux/buildinfo.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var sourceHashes = map[string]string{
"stdlib/array/array.flux": "178f1a855ac08069a24bb563be808ef4555e3f5f324f1cf7640090488c74d7c2",
"stdlib/array/array_test.flux": "649c3e017bca32c1cdbfef81288f84226dc5cac73be9975cb6b1286cd3637775",
"stdlib/array/from_test.flux": "a2c03db1a02f83100af7a6dfef09f377ec96a8a69acd1137688211b556405d2f",
"stdlib/contrib/RohanSreerama5/naiveBayesClassifier/bayes_test.flux": "a96250623b18f575f79e13a6642324fd2ade821512fbda92874dee703f7812ca",
"stdlib/contrib/RohanSreerama5/naiveBayesClassifier/bayes_test.flux": "0d276524b8568138aefe1257ff554bd12b726eec24325c24352cf68dee18e101",
"stdlib/contrib/RohanSreerama5/naiveBayesClassifier/naiveBayesClassifier.flux": "4df0b01c7678a4ea837cf0a06c5ecf649e83553e2875a6b13af5892583596266",
"stdlib/contrib/anaisdg/anomalydetection/mad.flux": "b323e2e2a5a6ac9be2ed1e255ccaa1ac7cc76a6989cecd29f0ffc9a787bf5701",
"stdlib/contrib/anaisdg/anomalydetection/mad_test.flux": "55f5f59a1f944f8704c8ebc46e08782e50d0cea3aa78c87c85eed3fe8dceeb98",
Expand Down
23 changes: 15 additions & 8 deletions stdlib/contrib/RohanSreerama5/naiveBayesClassifier/bayes_test.flux
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package naiveBayesClassifier_test


import "testing"
import "csv"
import "contrib/RohanSreerama5/naiveBayesClassifier"

option now = () => 2020-01-01T00:00:00Z
Expand Down Expand Up @@ -1533,8 +1534,16 @@ inData =
,,1503,2020-01-01T08:00:00Z,2020-08-21T15:44:03.401997Z,2020-01-07T15:49:25.987892129Z,0,wren,fins,zoo-data,1

"
outData =
"#group,false,false,false,false,false,true,false,true,true,false,false,false,false,false,false

testcase naive_bayes {
got =
csv.from(csv: inData)
|> naiveBayesClassifier.naiveBayes(myClass: "airborne", myField: "aquatic", myMeasurement: "zoo-data")

want =
csv.from(
csv:
"#group,false,false,false,false,false,true,false,true,true,false,false,false,false,false,false
#datatype,string,long,string,double,double,string,string,long,string,long,double,double,double,long,long
#default,MAIN,,,,,,,,,,,,,,
,result,table,Animal_name,P_x_k,Probability,_field_Probability_table,_field_r,_value,airborne_P_k_x_class,airborne_P_value_x,p_k,p_x,sum,tc_P_k_x_class,tc_P_value_x
Expand All @@ -1557,10 +1566,8 @@ outData =
,,3,carp,0.2631578947368421,0.17241379310344826,aquatic,aquatic,1,1,29,0.25675675675675674,0.3918918918918919,5,74,74
,,3,crab,0.2631578947368421,0.17241379310344826,aquatic,aquatic,1,1,29,0.25675675675675674,0.3918918918918919,5,74,74

"
t_naive_bayes = (table=<-) =>
table
|> naiveBayesClassifier.naiveBayes(myClass: "airborne", myField: "aquatic", myMeasurement: "zoo-data")
",
)

test _naive_bayes = () =>
({input: testing.loadStorage(csv: inData), want: testing.loadMem(csv: outData), fn: t_naive_bayes})
testing.diff(got: got, want: want)
}
1,330 changes: 2 additions & 1,328 deletions stdlib/contrib/RohanSreerama5/naiveBayesClassifier/flux_test_gen.go

Large diffs are not rendered by default.

0 comments on commit a0b00f9

Please sign in to comment.