0
$\begingroup$

I am just curious, and I wanted to know if it is possible to get the score of each prediction in a Multiclass Classification model. If it is possible, how can I implement this to make predictions on my original datasets and not the test_data and output the score of each prediction in a new column.

I made predictions on my original dataset to have the prediction columns named [predictions_final] I also want to make predictions on the original dataset to get the score or probabilities score to be in another column side by side with the prediction and my original dataset

######## BELOW IS THE CODE from sklearn.multiclass import OneVsRestClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import roc_curve, auc import scikitplot as skplt import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X3,y1, test_size=0.2, random_state=10) RFc = OneVsRestClassifier(RandomForestClassifier(max_features=0.2)) RFc.fit(X_train, y_train) y_pred = RFc.predict(X_test) pred_prob = RFc.predict_proba(X_test) skplt.metrics.plot_roc_curve(y_test, pred_prob) plt.show() y_pred = RFc.predict(X_test) from sklearn.metrics import classification_report,confusion_matrix print(classification_report(y_test,y_pred)) preded = RFc.predict(X_test) RFc.predict_proba(X_test) Final = RFc.predict(X3) X3['predictions_final']=Final ``` 
$\endgroup$
2
  • $\begingroup$ You should tell us at the very least if you use any ML library, e.g. scikit-learn, Keras, pytorch, etc, and, ideally, show us a snippet of your code to see how to answer your question accurately. $\endgroup$ Commented Oct 19, 2022 at 6:42
  • $\begingroup$ Thanks @noe I have added a snippet of my code. kindly go through it and see how you can help to answer the question $\endgroup$ Commented Oct 19, 2022 at 15:34

1 Answer 1

0
$\begingroup$

for example:

model.fit(x, y ,epochs=3 validation_split=0.2) prediction = model.predict(x_1) 

this will output the scores for each class if i'm not mistaken

print(prediction[0]) >>[[0.1 , 0.7, 0.2 ,0.5]] "if they are 4 classes" >>np.argmax(prediction[0]) "to get the actual class" 

i don't know if this answers your question

$\endgroup$
1
  • $\begingroup$ Thanks @Tunechi. I will try this out and see if it works for me. Once again, I am grateful $\endgroup$ Commented Oct 18, 2022 at 17:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.