diff --git a/test/test-dt1.js b/test/test-dt1.js new file mode 100644 index 0000000..be24a14 --- /dev/null +++ b/test/test-dt1.js @@ -0,0 +1,19 @@ +var x = [[0, 0, 0], [0, 1, 1], [1, 1, 0], [2, 2, 2], [1, 2, 2], [2, 1, 2]]; +var y = ['A', 'A', 'B', 'B', 'C', 'C']; +var model = ml.learn({ + algorithm:ml.ML.DT, + x:x, + y:y, + eps:0.2 +}); +print(toJSON(model).length+' Bytes') + +var test_data =[[0, 1.2, 0], + [2.1, 2, 3], + [2.1,1.1,2.0]]; + +print(ml.print(model)) +print(ml.classify(model,x)) +print(ml.classify(model,x.map(function (row) { return row.map(function (col) { return col+random(-0.3,0.3,0.001) })}))) +print(ml.classify(model,test_data)) +print(ml.classify(model,[1,2,3]))