相关疑难解决方法(0)

使用Sklearn的graphviz时出现错误

当我尝试使用以下命令导出随机森林图时:

tree.export_graphviz(rnd_clf, out_file = None, feature_names = X_test[::1])
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

NotFittedError: This RandomForestClassifier instance is not fitted yet. 
Call 'fit' with appropriate arguments before using this method.
Run Code Online (Sandbox Code Playgroud)

我不明白为什么它一直告诉我这个,即使我已经使用以下方法拟合随机森林分类器:

rnd_clf = RandomForestClassifier(  
             n_estimators=120,
             criterion='gini',
             max_features= None, 
             max_depth = 14 )

rnd_clf.fit(X_train, y_train)
Run Code Online (Sandbox Code Playgroud)

它完美无缺.

scikit-learn

15
推荐指数
2
解决办法
1万
查看次数

标签 统计

scikit-learn ×1