There are various Evaluation Metrics in Machine Learning. When measuring the performance of a model we consider metrics in order to know whether this model is performing how it is supposed to. is the performance good enough to make accurate predictions? These are some questions that get answered when evaluating a model. We are going to discuss the 8 Most Popular Evaluation Metrics in Machine Learning. Continue Reading to find out what they are.

## Table of Contents

## What are Evaluation Metrics?

Evaluation metrics are essential tools that allow us to quantify the performance of our models. These metrics provide valuable insights into how accurately our models are making predictions and help us make informed decisions about model improvements. It is crucial to evaluate the model in order to determine the model is the best performer.

Evaluation Metrics are different for different predictive models such as regression and classification, and as classification predictive models are generally of 2 types – class-based (which outputs a class as prediction 0 or 1 ) and probability-based (which outputs the probability of a feature being in that particular class).

## Regression Evaluation Metrics in Machine Learning

Two popular regression evaluation metrics in machine learning we are going to discuss. Regression tasks involve predicting continuous numerical values and the goal here is to estimate the relationship between input features and a continuous target variable. Here are some evaluating metrics used in regression models in machine learning:

**Root Mean Squared Error (RMSE):**

RMSE is the square root of MSE. It gives us a measure of the average magnitude of the errors in the predicted values. Like MSE, it’s sensitive to outliers. RMSE helps answer the question: “On average, how much is the model’s prediction deviating from the actual values of target variables?”

Note that, RMSE is sensitive to outliers because it squares the errors before averaging them. This means that larger errors contribute more to the RMSE, making it a suitable metric to penalize significant deviations between predictions and actual values.

**R-squared (Coefficient of Determination):**

R-squared, also known as the coefficient of determination, is a metric that assesses the proportion of variance in the target variable that is explained by the model. It’s a measure of how well the independent variables in the model account for the variability in the dependent variable.

The value of R-squared ranges from 0 to 1, with higher values indicating a better fit of the model to the data. However, a high R-squared doesn’t necessarily imply that the model is predictive; it might indicate overfitting if the model captures noise in the data.

## Classification Evaluation Metrics in Machine Learning

Classification in Machine Learning involves predicting discrete class labels or categorical values. As we already discussed it is of two types – class-based and probability-based. The goal is to assign an input instance to one of several predefined classes. The Evaluation metrics for Classification Models in Machine Learning are listed below:

### Precision

I’m sure you might have heard precision a lot of times, Precision is a vital evaluation metric, particularly in classification tasks. It quantifies the ability of a model to make accurate positive predictions among all the positive predictions it makes. In simpler terms, it measures how well a model avoids making false positive errors – that is, incorrectly classifying a negative instance as positive.

Precision is calculated by dividing the number of true positive predictions (instances correctly classified as positive) by the sum of true positive and false positive predictions (instances incorrectly classified as positive):

Hence, **Precision = True Positives / (True Positives + False Positives)**

Let’s take a real-world example to understand precision. Imagine you’re building a spam email filter, right? High precision in this context would mean that when your model flags an email as spam, it’s almost certain that the email is indeed spam, minimizing the chance of false alarms.

For instance, if your spam filter has a precision of 0.95, it signifies that out of every 100 emails it classifies as spam, approximately 95 of them are genuinely spam, and only about 5 are false positives.

### Recall

With Precision comes Recall, these terms generally go hand-in-hand. Recall is calculated as the ratio of true positives (correctly identified positive instances) to the sum of true positives and false negatives (positive instances that were missed by the model). It is expressed as:

**Recall = True Positives / (True Positives + False Negatives)**

This metric is often presented as a percentage or a value between 0 and 1. A recall score of 1 indicates that the model has captured all positive instances with perfection, while a score of 0 implies that none of the positive instances were detected.

Consider the same example of a spam email detection system. The consequences of missing a legitimate email in the spam folder might be inconvenient, but missing an actual spam email in the inbox could lead to disastrous outcomes. This is where recall steps in. By maximizing recall, the system ensures that it correctly identifies and moves spam emails to the spam folder, minimizing the chances of false negatives – an essential aspect in situations where missing actual positives is unacceptable.

### Confusion Matrix

Confusion Matrix is one of the most fundamental evaluation metrics in machine learning, particularly for evaluating the performance of classification models. The confusion matrix is a square table that arranges the predicted classes against the actual classes. It’s divided into four sections:

**True Positive (TP):**Instances that are correctly predicted as positive.**True Negative (TN):**Instances that are correctly predicted as negative.**False Positive (FP):**Instances that are incorrectly predicted as positive when they are actually negative.**False Negative (FN):**Instances that are incorrectly predicted as negative when they are actually positive.

Continuing the example of Spam Email Filter, if your model is aimed at identifying spam emails, the confusion matrix will tell you how many actual spam emails were classified correctly (TP) and how many were missed (FN). It will also reveal how many legitimate emails were incorrectly classified as spam (FP).

**Deriving Metrics:** From the confusion matrix, you can extract various metrics that help you gauge the model’s effectiveness:

**Accuracy:**The overall correctness of the model’s predictions, calculated as (TP + TN) / Total instances.**Precision:**The proportion of correctly predicted positive instances out of all instances predicted as positive, calculated as TP / (TP + FP).**Recall:**The proportion of actual positive instances that were correctly predicted, calculated as TP / (TP + FN).**F1 Score:**The harmonic mean of precision and recall, providing a balanced measure of accuracy.Accuracy

### AUC-ROC

Before we talk about AUC-ROC, let’s first understand the ROC curve itself. ROC is a graphical representation of a model’s performance as the discrimination threshold changes. In a binary classification scenario, the threshold determines when a predicted probability is classified as positive or negative. As the threshold varies, the model’s true positive rate (recall) and false positive rate change.

The ROC curve is created by plotting the true positive rate (TPR) on the y-axis against the false positive rate (FPR) on the x-axis. The TPR is also known as sensitivity or recall, while the FPR is the ratio of false positives to the total number of actual negatives.

AUC-ROC is a numerical measure derived from the ROC curve. It represents the area under the ROC curve. A model with a perfect ability to distinguish between classes will have an AUC-ROC score of 1, while a model that performs no better than random guessing will have an AUC-ROC score of 0.5.

**Robustness to Class Imbalance:**AUC-ROC is particularly useful when dealing with imbalanced datasets, where one class has significantly more instances than the other. It provides a balanced perspective of model performance by considering both true positive and false positive rates.**Threshold Independence:**Unlike metrics like accuracy or F1 score, AUC-ROC is not affected by the choice of threshold. It evaluates the model’s performance across a range of thresholds, providing a comprehensive view.**Model Comparison:**AUC-ROC is an excellent tool for comparing different models’ performances. Models with higher AUC-ROC scores generally exhibit better discrimination capabilities.**Visualization:**The ROC curve and AUC-ROC are not only informative but also visually appealing. They provide a clear visual representation of a model’s trade-offs between sensitivity and specificity.

AUC-ROC is especially relevant when the cost of false positives and false negatives varies, and you want to find a balance between the two. It’s commonly used in medical diagnostics (where false negatives could have severe consequences), fraud detection (where false positives might lead to inconvenience), and various other applications where class separation matters.

### F1-Score

The F1 score is a balance between precision and recall. It’s particularly valuable when the distribution of classes in your dataset is uneven or when you want to avoid extreme cases of either false positives or false negatives. It is calculated as:

**F-1 Score = 2 * ((recall * precision) / (recall + precision))**

A high F1 score indicates that the model has achieved a good balance between precision and recall. However, in some cases, precision might be more critical, and in others, recall might take precedence.

For example, in medical diagnoses, missing positive cases (false negatives) can be life-threatening. At the same time, wrongly diagnosing a healthy person (false positives) can lead to unnecessary stress and additional medical procedures. The F1 score helps balance these concerns.

## Conclusion

In Conclusion, we discussed the 8 most popular model evaluation metrics in machine learning that are widely used in one or another machine learning problem. Here are some key metrics that we talked about: **RMSE and R-squared (Regression)** | **Precision, Recall, Confusion Matrix, F1-Score, AUC-ROC, and Accuracy (Classification). **You should know these fundamental evaluation metrics in machine learning as they will be highly useful when executing projects either of regression-based problems or classification-based problems. You can head over to the scikit-learn evaluation metrics documentation and learn more about their usage.

**Read More:**

## Leave a Reply