From cecb2f308555cd2e294a6331368547d10a530832 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:15:00 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-dt2.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/test-dt2.js 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}))