Tue 27 Aug 00:14:56 CEST 2024

This commit is contained in:
sbosse 2024-08-27 00:15:27 +02:00
parent bf773fdac0
commit 3c5406e9de

45
test/test-slp2.js Normal file
View File

@ -0,0 +1,45 @@
var x = csv.read('test-c45-3-X.csv'),
y = csv.read('test-c45-3-Y.csv');
x.shift();
y.shift();
var classes=[
'H1None',
'H2None',
'H3None',
'H4None',
'H5None',
'H6None',
'H7None',
'H8None',
'H9None',
'NoneNone',
];
var t0=time();
var model = ml.learn({
algorithm : ml.ML.SLP,
x : x,
y : y,
labels:classes,
normalize:true,
// bipolar:true,
epochs : 20000,
});
var t1=time()
print(toJSON(model).length+' Bytes')
print((t1-t0)+'ms');
var targets,samples = csv.read('test-c45-3-S.csv');
samples.shift();
targets=ml.stats.utils.column(samples,x[0].length);
samples=ml.stats.utils.select(samples,[0,x[0].length-1]);
for(var i=0;i<samples.length;i++)
print(classes.indexOf(targets[i]+'None'),
ml.stats.utils.best(ml.classify(model,samples[i])));
print(ml.classify(model,samples[0]));