Olearn
Olearn is a Node.js module implementing the online random forests algorithm,
as specified by Saffari et al (2009),
with some minor adaptations.
At some point, I hope to add more algorithms to this library.
Please note that the current version may be very buggy, so only use for experimentation.
Example usage
Initialise a forest
var OnlineForest = require("olearn").OnlineForest,
of;
of = new OnlineForest({
numTrees: 10,
numTests: 20,
maxDepth: 6,
splitThreshold: 0.01,
minSeen: 1000,
rangeTrialNum: 1000,
featureTypes: ["continuous", "continuous", "discrete"]
});
If the feature range is known in advance, set rangeTrialNum: 0
and specify ranges
and rangeTypes
:
ranges: [[-10, 10], [-10, 10], ["london", "glasgow", ...]],
rangeTypes: ["interval", "interval", "set"]
Update (train) the forest
of.update({
features: [5, 2, "london"],
label: "hot"
});
of.update({
features: [-1, -5, "glasgow"],
label: "cold"
});
(You'll need many more samples than this!)
Make a prediction
of.predict({
features: [3, 5, "manchester"]
})
Example output:
{
confidence: {"hot": 0.4, "cold": 0.6},
label: "cold"
}