Menu

Evaluating Model Performance

Evaluating Model Performance

After making predictions, the final step is to check how well the model performed using proper evaluation metrics rather than guesswork.

from sklearn.metrics import accuracy_score, confusion_matrix, classification_report

accuracy = accuracy_score(y_test, predictions)
print("Accuracy:", accuracy)

print(confusion_matrix(y_test, predictions))
print(classification_report(y_test, predictions))

Code Explanation

  • accuracy_score(y_test, predictions) calculates the percentage of correct predictions out of all test samples.
  • confusion_matrix(y_test, predictions) shows exactly how many predictions were correct or incorrect, broken down by species.
  • classification_report(y_test, predictions) displays precision, recall, and F1 score for each species individually.

Accuracy Formula

Accuracy = Correct Predictions / Total Predictions

Once these results are generated, you should see a high accuracy score, often above 95 percent, since the Iris dataset is clean and well separated.


Machine Learning Tutorial

AP

Abhishek Pati



Learn via Video Course

Artificial Intelligence and Machine Learning Course Logo

Artificial Intelligence and Machine Learning Course

55 hrs



Get in Touch For Details