[英]AxisError: axis 1 is out of bounds for array of dimension 1 when calculating roc_auc_score
rf = RandomForestClassifier(max_features=5, n_estimators=500)
rf.fit(d2_train_dataset, Y_train)
nb = GaussianNB()
nb.fit(d2_train_dataset, Y_train)
rf_probs = rf.predict_proba(d2_train_dataset)
nb_probs = nb.predict_proba(d2_train_dataset)
rf_probs = rf_probs[:, 1]
nb_probs = nb_probs[:, 1]
rf_auc = roc_auc_score(Y_test, rf_probs,multi_class="ovo")
nb_auc = roc_auc_score(Y_test, nb_probs,multi_class="ovo")
then this is the error "AxisError: axis 1 is out of bounds for array of dimension 1" in this cell那么这是此单元格中的错误“AxisError:axis 1 is out of bounds for array of dimension 1”
rf_auc = roc_auc_score(Y_test, rf_probs,multi_class="ovo")
nb_auc = roc_auc_score(Y_test, nb_probs,multi_class="ovo")
got the same problem, but this worked in my case, check my answer once遇到了同样的问题,但这在我的情况下有效,请检查我的答案一次
roc_auc_score(Y_test,rf_probs,multi_cass = "ovo",average= "weighted")
else, try without these two steps否则,请尝试不执行这两个步骤
rf_probs = rf_probs[:, 1]
nb_probs = nb_probs[:, 1]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.