Published
Edited
Mar 25, 2018
Insert cell
Insert cell
Insert cell
Insert cell
forest = require('https://bundle.run/random-forest-classifier@0.6.0')
Insert cell
Insert cell
Insert cell
RandomForestClassifier = forest.RandomForestClassifier
Insert cell
Insert cell
Insert cell
Insert cell
iris.length
Insert cell
trainDataLength = iris.length*0.80
Insert cell
irisTrain = iris.slice(0,trainDataLength)
Insert cell
irisTest = iris.slice(trainDataLength,iris.length)
Insert cell
Insert cell
rf = new RandomForestClassifier({
n_estimators: 10
})
Insert cell
Insert cell
Insert cell
Insert cell
answer = []
Insert cell
Insert cell
fit(irisTrain,["sepalLength", "sepalWidth"], "species", function(err,trees){getOut(rf.trees)})
Insert cell
Insert cell
answerReally = pred(irisTest, answer)
Insert cell
Insert cell
answerReally.length
Insert cell
function getOut(pred){
answer.push(pred)
return answer
}
Insert cell
Insert cell
Insert cell
Insert cell
rfNew = new RandomForestClassifier2({
n_estimators: 20
})
Insert cell
fit2 = rfNew["fit"]
Insert cell
pred2 = rfNew["predict"]
Insert cell
answer2 = []
Insert cell
// fit2(irisTrain, ["sepalLength", "sepalWidth"], "species",function(err,trees){getOut2(rfNew.trees)})
// fit(irisTrain,["sepalLength", "sepalWidth"], "species", function(err,trees){getOut(rf.trees)})
Insert cell
// answerForPred2 = pred2(irisTest,answer2)
Insert cell
fit2(irisTrain, ["sepalLength", "sepalWidth"], "species",function(err,trees){
let results2 = pred2(irisTest,trees)
console.log("test JUSTIN",trees)
// var pred = pred2(irisTest, rfNew.trees);
attemptArray.push(results2)
})
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more