Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
parent
4bb33be0ff
commit
cecb2f3085
24
test/test-dt2.js
Normal file
24
test/test-dt2.js
Normal file
|
@ -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}))
|
Loading…
Reference in New Issue
Block a user