<p>我通过使用<code>GridSearchCV</code>对您的模型进行了很好的改进</p>
<pre><code>from sklearn.datasets import fetch_covtype
from sklearn.ensemble import RandomForestClassifier
from sklearn import cross_validation
from sklearn import grid_search
import numpy as np
covtype = fetch_covtype()
clf = RandomForestClassifier()
X_train, X_test, y_train, y_test = cross_validation.train_test_split(covtype.data,
covtype.target,
test_size=0.33,
random_state=42)
params = {'n_estimators':[30, 50, 100],
'max_features':['sqrt', 'log2', 10]}
gsv = grid_search.GridSearchCV(clf, params, cv=3,
n_jobs=-1, scoring='f1')
gsv.fit(X_train, y_train)
print metrics.classification_report(y_train, gsv.best_estimator_.predict(X_train))
print metrics.classification_report(y_test, gsv.best_estimator_.predict(X_test))
</code></pre>
<p>输出:</p>
^{pr2}$
<p>这与<a href="https://www.kaggle.com/c/forest-cover-type-prediction/leaderboard" rel="nofollow">Kaggle leaderboard</a>的分数相差不远(请注意,Kaggle竞赛使用的是更具挑战性的数据分割!)在</p>
<p>如果你想看到更多的改进,那么你必须考虑不均衡的课程以及如何最好地选择你的培训数据。在</p>
<p><strong>注意</strong></p>
<p>为了节省时间,我使用了比通常情况下更少的估计量,但是模型在训练集上表现良好,所以您可能不必考虑这一点。在</p>
<p>我使用了少量的<code>max_features</code>,因为这通常会减少模型训练中的偏差。虽然这并不总是真的。在</p>
<p>我使用了<code>f1</code>评分,因为我不太了解数据集,<code>f1</code>往往在分类问题上工作得很好。在</p>