Skip to content

Commit

Permalink
random forest bits added
Browse files Browse the repository at this point in the history
  • Loading branch information
JustGlowing committed Aug 25, 2015
1 parent dcdf8fc commit f7e4fdf
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 100 deletions.
25 changes: 15 additions & 10 deletions EuroScipy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -650,16 +650,15 @@
},
"outputs": [],
"source": [
"##### TO BE FIXED!!! ##### \n",
"parameters = [{'n_estimators': [5, 10, 20, 50, 100], \n",
" 'max_depth': [5, 10, 15]}] \n",
"\n",
"# Define the parameters to be optimised and their values/ranges\n",
"\n",
"parameters = [{\"n_estimators\": [250, 500, 1000]}]\n",
"sample_leaf_options = [1,5,10,50,100,200,500]\n",
"\n",
"###### WHAT ELSE DO WE ADD HERE?!?!?!!? ###### \n",
"grid = GridSearchCV(RandomForestClassifier(), parameters, cv=10) \n",
"grid.fit(XTrain, yTrain)\n",
"\n",
"##### DO WE TUNE WITH A GRID SEARCH??? ##### \n"
"best_n_estim = grid.best_params_['n_estimators']\n",
"best_max_depth = grid.best_params_['max_depth']\n",
"print \"The best parameters are: n_estimators=\", best_n_estim, \" and max_depth=\", best_max_depth"
]
},
{
Expand All @@ -686,7 +685,13 @@
"#################################################################################### \n",
"\n",
"\n",
"## WE HAVE NO SOLUTION"
"## Solution ## \n",
"clfRDF = RandomForestClassifier(n_estimators=best_n_estim, max_depth=best_max_depth)\n",
"clfRDF.fit(XTrain, yTrain)\n",
"predRF = clfRDF.predict(XTest)\n",
"\n",
"print metrics.classification_report(yTest, predRF)\n",
"print \"Overall Accuracy:\", round(metrics.accuracy_score(yTest, predRF),2)"
]
},
{
Expand Down Expand Up @@ -1356,7 +1361,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
"version": "2.7.8"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit f7e4fdf

Please sign in to comment.