1.随机森林
from sklearn.ensemble import RandomForestClassifier
random_forest = RandomForestClassifier(n_estimators=100)
random_forest.fit(X_train, Y_train)
Y_pred = random_forest.predict(X_test)
acc_random_forest = round(random_forest.score(X_train, Y_train) * 100, 2)
print( '准确率:',acc_random_forest,'%')
#输出 准确率:93.6%
2.XGBoost
from xgboost import XGBClassifier
xgb=XGBClassifier()
xgb.fit(X_train, Y_train)
Y_pred = xgb.predict(X_test)
acc_xgb = round(xgb.score(X_train, Y_train) * 100, 2)
print( '准确率',acc_xgb,'%')
这里不知道是代码有问题还是电脑有问题,结果出不来。
用jupyter notebook运行会提示服务器挂掉了,用pycharm运行显示"Process finished with exit code -1073740791 (0xC0000409)",有没有大神知道怎么回事?