jam/test/test-c45-4.js

1026 lines
16 KiB
JavaScript

var training_data = [
{
"slength": 5.1,
"swidth": 3.5,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.9,
"swidth": 3.0,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.7,
"swidth": 3.2,
"plength": 1.3,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.6,
"swidth": 3.1,
"plength": 1.5,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.6,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.4,
"swidth": 3.9,
"plength": 1.7,
"pwidth": 0.4,
"variety": "Setosa"
},
{
"slength": 4.6,
"swidth": 3.4,
"plength": 1.4,
"pwidth": 0.3,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.4,
"plength": 1.5,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.4,
"swidth": 2.9,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.9,
"swidth": 3.1,
"plength": 1.5,
"pwidth": 0.1,
"variety": "Setosa"
},
{
"slength": 5.4,
"swidth": 3.7,
"plength": 1.5,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.8,
"swidth": 3.4,
"plength": 1.6,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.8,
"swidth": 3.0,
"plength": 1.4,
"pwidth": 0.1,
"variety": "Setosa"
},
{
"slength": 4.3,
"swidth": 3.0,
"plength": 1.1,
"pwidth": 0.1,
"variety": "Setosa"
},
{
"slength": 5.8,
"swidth": 4.0,
"plength": 1.2,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.7,
"swidth": 4.4,
"plength": 1.5,
"pwidth": 0.4,
"variety": "Setosa"
},
{
"slength": 5.4,
"swidth": 3.9,
"plength": 1.3,
"pwidth": 0.4,
"variety": "Setosa"
},
{
"slength": 5.1,
"swidth": 3.5,
"plength": 1.4,
"pwidth": 0.3,
"variety": "Setosa"
},
{
"slength": 5.7,
"swidth": 3.8,
"plength": 1.7,
"pwidth": 0.3,
"variety": "Setosa"
},
{
"slength": 5.1,
"swidth": 3.8,
"plength": 1.5,
"pwidth": 0.3,
"variety": "Setosa"
},
{
"slength": 5.4,
"swidth": 3.4,
"plength": 1.7,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.1,
"swidth": 3.7,
"plength": 1.5,
"pwidth": 0.4,
"variety": "Setosa"
},
{
"slength": 4.6,
"swidth": 3.6,
"plength": 1.0,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.1,
"swidth": 3.3,
"plength": 1.7,
"pwidth": 0.5,
"variety": "Setosa"
},
{
"slength": 4.8,
"swidth": 3.4,
"plength": 1.9,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.0,
"plength": 1.6,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.4,
"plength": 1.6,
"pwidth": 0.4,
"variety": "Setosa"
},
{
"slength": 5.2,
"swidth": 3.5,
"plength": 1.5,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.2,
"swidth": 3.4,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.7,
"swidth": 3.2,
"plength": 1.6,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.2,
"swidth": 4.1,
"plength": 1.5,
"pwidth": 0.1,
"variety": "Setosa"
},
{
"slength": 5.5,
"swidth": 4.2,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.9,
"swidth": 3.1,
"plength": 1.5,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.2,
"plength": 1.2,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.5,
"swidth": 3.5,
"plength": 1.3,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.9,
"swidth": 3.6,
"plength": 1.4,
"pwidth": 0.1,
"variety": "Setosa"
},
{
"slength": 4.4,
"swidth": 3.0,
"plength": 1.3,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.1,
"swidth": 3.4,
"plength": 1.5,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.5,
"plength": 1.3,
"pwidth": 0.3,
"variety": "Setosa"
},
{
"slength": 4.5,
"swidth": 2.3,
"plength": 1.3,
"pwidth": 0.3,
"variety": "Setosa"
},
{
"slength": 4.4,
"swidth": 3.2,
"plength": 1.3,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.5,
"plength": 1.6,
"pwidth": 0.6,
"variety": "Setosa"
},
{
"slength": 5.1,
"swidth": 3.8,
"plength": 1.9,
"pwidth": 0.4,
"variety": "Setosa"
},
{
"slength": 4.8,
"swidth": 3.0,
"plength": 1.4,
"pwidth": 0.3,
"variety": "Setosa"
},
{
"slength": 5.1,
"swidth": 3.8,
"plength": 1.6,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 4.6,
"swidth": 3.2,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.3,
"swidth": 3.7,
"plength": 1.5,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 5.0,
"swidth": 3.3,
"plength": 1.4,
"pwidth": 0.2,
"variety": "Setosa"
},
{
"slength": 7.0,
"swidth": 3.2,
"plength": 4.7,
"pwidth": 1.4,
"variety": "Versicolor"
},
{
"slength": 6.4,
"swidth": 3.2,
"plength": 4.5,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 6.9,
"swidth": 3.1,
"plength": 4.9,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 5.5,
"swidth": 2.3,
"plength": 4.0,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 6.5,
"swidth": 2.8,
"plength": 4.6,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 5.7,
"swidth": 2.8,
"plength": 4.5,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 6.3,
"swidth": 3.3,
"plength": 4.7,
"pwidth": 1.6,
"variety": "Versicolor"
},
{
"slength": 4.9,
"swidth": 2.4,
"plength": 3.3,
"pwidth": 1.0,
"variety": "Versicolor"
},
{
"slength": 6.6,
"swidth": 2.9,
"plength": 4.6,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 5.2,
"swidth": 2.7,
"plength": 3.9,
"pwidth": 1.4,
"variety": "Versicolor"
},
{
"slength": 5.0,
"swidth": 2.0,
"plength": 3.5,
"pwidth": 1.0,
"variety": "Versicolor"
},
{
"slength": 5.9,
"swidth": 3.0,
"plength": 4.2,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 6.0,
"swidth": 2.2,
"plength": 4.0,
"pwidth": 1.0,
"variety": "Versicolor"
},
{
"slength": 6.1,
"swidth": 2.9,
"plength": 4.7,
"pwidth": 1.4,
"variety": "Versicolor"
},
{
"slength": 5.6,
"swidth": 2.9,
"plength": 3.6,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 6.7,
"swidth": 3.1,
"plength": 4.4,
"pwidth": 1.4,
"variety": "Versicolor"
},
{
"slength": 5.6,
"swidth": 3.0,
"plength": 4.5,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 5.8,
"swidth": 2.7,
"plength": 4.1,
"pwidth": 1.0,
"variety": "Versicolor"
},
{
"slength": 6.2,
"swidth": 2.2,
"plength": 4.5,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 5.6,
"swidth": 2.5,
"plength": 3.9,
"pwidth": 1.1,
"variety": "Versicolor"
},
{
"slength": 5.9,
"swidth": 3.2,
"plength": 4.8,
"pwidth": 1.8,
"variety": "Versicolor"
},
{
"slength": 6.1,
"swidth": 2.8,
"plength": 4.0,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 6.3,
"swidth": 2.5,
"plength": 4.9,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 6.1,
"swidth": 2.8,
"plength": 4.7,
"pwidth": 1.2,
"variety": "Versicolor"
},
{
"slength": 6.4,
"swidth": 2.9,
"plength": 4.3,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 6.6,
"swidth": 3.0,
"plength": 4.4,
"pwidth": 1.4,
"variety": "Versicolor"
},
{
"slength": 6.8,
"swidth": 2.8,
"plength": 4.8,
"pwidth": 1.4,
"variety": "Versicolor"
},
{
"slength": 6.7,
"swidth": 3.0,
"plength": 5.0,
"pwidth": 1.7,
"variety": "Versicolor"
},
{
"slength": 6.0,
"swidth": 2.9,
"plength": 4.5,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 5.7,
"swidth": 2.6,
"plength": 3.5,
"pwidth": 1.0,
"variety": "Versicolor"
},
{
"slength": 5.5,
"swidth": 2.4,
"plength": 3.8,
"pwidth": 1.1,
"variety": "Versicolor"
},
{
"slength": 5.5,
"swidth": 2.4,
"plength": 3.7,
"pwidth": 1.0,
"variety": "Versicolor"
},
{
"slength": 5.8,
"swidth": 2.7,
"plength": 3.9,
"pwidth": 1.2,
"variety": "Versicolor"
},
{
"slength": 6.0,
"swidth": 2.7,
"plength": 5.1,
"pwidth": 1.6,
"variety": "Versicolor"
},
{
"slength": 5.4,
"swidth": 3.0,
"plength": 4.5,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 6.0,
"swidth": 3.4,
"plength": 4.5,
"pwidth": 1.6,
"variety": "Versicolor"
},
{
"slength": 6.7,
"swidth": 3.1,
"plength": 4.7,
"pwidth": 1.5,
"variety": "Versicolor"
},
{
"slength": 6.3,
"swidth": 2.3,
"plength": 4.4,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 5.5,
"swidth": 2.6,
"plength": 4.4,
"pwidth": 1.2,
"variety": "Versicolor"
},
{
"slength": 6.1,
"swidth": 3.0,
"plength": 4.6,
"pwidth": 1.4,
"variety": "Versicolor"
},
{
"slength": 5.8,
"swidth": 2.6,
"plength": 4.0,
"pwidth": 1.2,
"variety": "Versicolor"
},
{
"slength": 5.0,
"swidth": 2.3,
"plength": 3.3,
"pwidth": 1.0,
"variety": "Versicolor"
},
{
"slength": 5.6,
"swidth": 2.7,
"plength": 4.2,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 5.7,
"swidth": 3.0,
"plength": 4.2,
"pwidth": 1.2,
"variety": "Versicolor"
},
{
"slength": 5.7,
"swidth": 2.9,
"plength": 4.2,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 6.2,
"swidth": 2.9,
"plength": 4.3,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 5.1,
"swidth": 2.5,
"plength": 3.0,
"pwidth": 1.1,
"variety": "Versicolor"
},
{
"slength": 5.7,
"swidth": 2.8,
"plength": 4.1,
"pwidth": 1.3,
"variety": "Versicolor"
},
{
"slength": 6.3,
"swidth": 3.3,
"plength": 6.0,
"pwidth": 2.5,
"variety": "Virginica"
},
{
"slength": 5.8,
"swidth": 2.7,
"plength": 5.1,
"pwidth": 1.9,
"variety": "Virginica"
},
{
"slength": 7.1,
"swidth": 3.0,
"plength": 5.9,
"pwidth": 2.1,
"variety": "Virginica"
},
{
"slength": 6.3,
"swidth": 2.9,
"plength": 5.6,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.5,
"swidth": 3.0,
"plength": 5.8,
"pwidth": 2.2,
"variety": "Virginica"
},
{
"slength": 7.6,
"swidth": 3.0,
"plength": 6.6,
"pwidth": 2.1,
"variety": "Virginica"
},
{
"slength": 4.9,
"swidth": 2.5,
"plength": 4.5,
"pwidth": 1.7,
"variety": "Virginica"
},
{
"slength": 7.3,
"swidth": 2.9,
"plength": 6.3,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.7,
"swidth": 2.5,
"plength": 5.8,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 7.2,
"swidth": 3.6,
"plength": 6.1,
"pwidth": 2.5,
"variety": "Virginica"
},
{
"slength": 6.5,
"swidth": 3.2,
"plength": 5.1,
"pwidth": 2.0,
"variety": "Virginica"
},
{
"slength": 6.4,
"swidth": 2.7,
"plength": 5.3,
"pwidth": 1.9,
"variety": "Virginica"
},
{
"slength": 6.8,
"swidth": 3.0,
"plength": 5.5,
"pwidth": 2.1,
"variety": "Virginica"
},
{
"slength": 5.7,
"swidth": 2.5,
"plength": 5.0,
"pwidth": 2.0,
"variety": "Virginica"
},
{
"slength": 5.8,
"swidth": 2.8,
"plength": 5.1,
"pwidth": 2.4,
"variety": "Virginica"
},
{
"slength": 6.4,
"swidth": 3.2,
"plength": 5.3,
"pwidth": 2.3,
"variety": "Virginica"
},
{
"slength": 6.5,
"swidth": 3.0,
"plength": 5.5,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 7.7,
"swidth": 3.8,
"plength": 6.7,
"pwidth": 2.2,
"variety": "Virginica"
},
{
"slength": 7.7,
"swidth": 2.6,
"plength": 6.9,
"pwidth": 2.3,
"variety": "Virginica"
},
{
"slength": 6.0,
"swidth": 2.2,
"plength": 5.0,
"pwidth": 1.5,
"variety": "Virginica"
},
{
"slength": 6.9,
"swidth": 3.2,
"plength": 5.7,
"pwidth": 2.3,
"variety": "Virginica"
},
{
"slength": 5.6,
"swidth": 2.8,
"plength": 4.9,
"pwidth": 2.0,
"variety": "Virginica"
},
{
"slength": 7.7,
"swidth": 2.8,
"plength": 6.7,
"pwidth": 2.0,
"variety": "Virginica"
},
{
"slength": 6.3,
"swidth": 2.7,
"plength": 4.9,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.7,
"swidth": 3.3,
"plength": 5.7,
"pwidth": 2.1,
"variety": "Virginica"
},
{
"slength": 7.2,
"swidth": 3.2,
"plength": 6.0,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.2,
"swidth": 2.8,
"plength": 4.8,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.1,
"swidth": 3.0,
"plength": 4.9,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.4,
"swidth": 2.8,
"plength": 5.6,
"pwidth": 2.1,
"variety": "Virginica"
},
{
"slength": 7.2,
"swidth": 3.0,
"plength": 5.8,
"pwidth": 1.6,
"variety": "Virginica"
},
{
"slength": 7.4,
"swidth": 2.8,
"plength": 6.1,
"pwidth": 1.9,
"variety": "Virginica"
},
{
"slength": 7.9,
"swidth": 3.8,
"plength": 6.4,
"pwidth": 2.0,
"variety": "Virginica"
},
{
"slength": 6.4,
"swidth": 2.8,
"plength": 5.6,
"pwidth": 2.2,
"variety": "Virginica"
},
{
"slength": 6.3,
"swidth": 2.8,
"plength": 5.1,
"pwidth": 1.5,
"variety": "Virginica"
},
{
"slength": 6.1,
"swidth": 2.6,
"plength": 5.6,
"pwidth": 1.4,
"variety": "Virginica"
},
{
"slength": 7.7,
"swidth": 3.0,
"plength": 6.1,
"pwidth": 2.3,
"variety": "Virginica"
},
{
"slength": 6.3,
"swidth": 3.4,
"plength": 5.6,
"pwidth": 2.4,
"variety": "Virginica"
},
{
"slength": 6.4,
"swidth": 3.1,
"plength": 5.5,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.0,
"swidth": 3.0,
"plength": 4.8,
"pwidth": 1.8,
"variety": "Virginica"
},
{
"slength": 6.9,
"swidth": 3.1,
"plength": 5.4,
"pwidth": 2.1,
"variety": "Virginica"
},
{
"slength": 6.7,
"swidth": 3.1,
"plength": 5.6,
"pwidth": 2.4,
"variety": "Virginica"
},
{
"slength": 6.9,
"swidth": 3.1,
"plength": 5.1,
"pwidth": 2.3,
"variety": "Virginica"
},
{
"slength": 5.8,
"swidth": 2.7,
"plength": 5.1,
"pwidth": 1.9,
"variety": "Virginica"
},
{
"slength": 6.8,
"swidth": 3.2,
"plength": 5.9,
"pwidth": 2.3,
"variety": "Virginica"
},
{
"slength": 6.7,
"swidth": 3.3,
"plength": 5.7,
"pwidth": 2.5,
"variety": "Virginica"
},
{
"slength": 6.7,
"swidth": 3.0,
"plength": 5.2,
"pwidth": 2.3,
"variety": "Virginica"
},
{
"slength": 6.3,
"swidth": 2.5,
"plength": 5.0,
"pwidth": 1.9,
"variety": "Virginica"
},
{
"slength": 6.5,
"swidth": 3.0,
"plength": 5.2,
"pwidth": 2.0,
"variety": "Virginica"
}
]
var target = "variety";
var features = ["slength", "swidth","plength","pwidth"];
var model = ml.learn({
algorithm:ml.ML.C45,
data:training_data,
target:target,
features:features
})
print(ml.print(model))
print(ml.classify(model,training_data))