diff --git a/test/test-dt2.js b/test/test-dt2.js new file mode 100644 index 0000000..a573dc9 --- /dev/null +++ b/test/test-dt2.js @@ -0,0 +1,24 @@ +var data = [ + {a:0, b:0, c:0, y:'A'}, + {a:0, b:1, c:1, y:'A'}, + {a:1, b:1, c:0, y:'B'}, + {a:2, b:2, c:2, y:'B'}, + {a:1, b:2, c:2, y:'C'}, + {a:2, b:1, c:2, y:'C'} + ]; +var model = ml.learn({ + algorithm:ml.ML.DT, + data:data, + target:'y', + features:['a','b','c'], + eps:0.2 +}); +print(toJSON(model).length+' Bytes') + +var test_data =[{a:0, b:1.2, c:0}, + {a:2.1, b:2, c:3}, + {a:2.1, b:1.1, c:2.0}]; + +print(ml.print(model)) +print(ml.classify(model,test_data)) +print(ml.classify(model,{a:1,b:2,c:3}))