我有一个使用 scikit 学习的随机森林模型,如下所示:
model = RandomForestClassifier(criterion='gini',n_estimators=700,min_samples_split=4,min_samples_leaf=1,max_features='auto',oob_score=True,random_state=1,n_jobs=-1)
model.fit(X_train,y_train)
y_pred_rm=model.predict(X_test)
print('--------------The Accuracy of the model---------------------------')
kfold = KFold(n_splits=10, random_state=22)
result_rm = cross_val_score(model, all_features, Targeted_feature, cv=10, scoring = 'accuracy')
print('The cross validated score for Random Forest Classifier is:',round(result_rm.mean()*100,2))
y_pred = cross_val_predict(model,all_features,Targeted_feature,cv=10)
kfold = KFold(n_splits=5, random_state=22)
result_rm1 = cross_val_score(model, all_features, Targeted_feature, cv=5, scoring='accuracy')
print('The cross validated score (5)for Random Forest Classifier is:',round(result_rm1.mean()*100,2))
sns.heatmap(confusion_matrix(Targeted_feature,y_pred),annot=True,fmt='3.0f',cmap="winter")
plt.title('Confusion_matrix', y=1.05, size=15)
我一直在尝试优化我的模型,但还没有取得任何成功。我在测试数据集上达到的最高准确率是 78%。您有任何想法或步骤可以改进我的模型吗?
慕容森
慕妹3146593
相关分类