我已经拆分了训练数据并初始化了 11 个分类器模型,我现在想比较这些模型。
我在 Ubuntu 18.04 上运行 VS Code。
我试过了:
# Prepare lists
models = [ran, knn, log, xgb, gbc, svc, ext, ada, gnb, gpc, bag]
scores = []
# Sequentially fit and cross validate all models
for mod in models:
mod.fit(X_train, y_train)
acc = cross_val_score(mod, X_train, y_train, scoring =
"accuracy", cv = 10)
scores.append(acc.mean())
# Creating a table of results, ranked highest to lowest
results = pd.DataFrame({
'Model': ['Random Forest', 'K Nearest Neighbour', 'Logistic
Regression', 'XGBoost', 'Gradient Boosting', 'SVC', 'Extra
Trees', 'AdaBoost', 'Gaussian Naive Bayes', 'Gaussian Process',
'Bagging Classifier'],
'Score': scores})
最后一部分返回:
ValueError:数组的长度必须相同
我数了 2 倍,确实有 11 个模型。
我错过了什么?
月关宝盒
长风秋雁
相关分类