Added Random Forest training section.

This commit is contained in:
Donne Martin 2015-03-20 11:33:41 -04:00
parent ad54e0ae70
commit 3fcbc8364f

View File

@ -2352,6 +2352,56 @@
"metadata": {},
"outputs": [],
"prompt_number": 37
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Random Forest: Training"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create the random forest object:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"forest = RandomForestClassifier(n_estimators=100)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 38
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Fit the training data and create the decision trees:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Training data (features), skip the first column 'Survived'\n",
"training_input = train_data[0::, 1::]\n",
"\n",
"# 'Survived' column values\n",
"target_values = train_data[0::, 0]\n",
"\n",
"# Fit the model to our training data\n",
"forest = forest.fit(training_input, target_values)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 39
}
],
"metadata": {}