Skip to content

Instantly share code, notes, and snippets.

@brh55
Created November 19, 2015 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brh55/66a22ed02fdc3b80bf33 to your computer and use it in GitHub Desktop.
Save brh55/66a22ed02fdc3b80bf33 to your computer and use it in GitHub Desktop.
reddit analytics
// TODO: Will like to get back to this if I have time.
// Goal would be to iterate through with a instance set containing different days and MostComments and Score. Then suggest the day with greatest probability based on model.
// if (model.postList.length > 0) {
// var forest = new forestjs.RandomForest();
// var options = {}
// options.numTrees = 100;
// options.maxDepth = 5;
// options.numTries = 10;
// TODO: COME BACK TO And figure out why it's not working.
// options.trainFun = function(data, labels, ix, options) {
// // save parameters that describe your model
// model.parameter1 = 40;
// model.parameter2 = 10;
// return model;
// };
// options.testFun = function(inst, model) {
// console.log(a);
// // use model.parameter1 and model.parameter2 to return a 1 or -1 for
// // example instance inst. This determines if it will be passed down
// // left or right in the tree.
// return inst[0] > model.parameter1 ? 1 : -1; // silly example
// };
// forest.train(model.postList, ["score", "commentsCount", "weekDay"], options);
// var predictionList = [];
// for (var days = 0; days <= 7; days++) {
// predictionList.push([model.bestScore, model.mostComments]);
// }
// var testInstance = [10000];
// var labelProbability = forest.predict(predictionList);
// console.log(labelProbability);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment