'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

rf_auc = roc_auc_score(Y_test, rf_probs,multi_class="ovo")
nb_auc = roc_auc_score(Y_test, nb_probs,multi_class="ovo")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source