2-Training and Testing Models, Evaluation Metrics-01-07-2023
2-Training and Testing Models, Evaluation Metrics-01-07-2023
33
34
Training Vs Testing
• The main difference between training data and
testing data is that training data is the subset of
original data that is used to train the machine
learning model, whereas testing data is used to
check the accuracy of the model.
• The training dataset is generally larger in size
compared to the testing dataset. The general ratios
of splitting train and test datasets are 80:20, 70:30,
or 90:10.
• Training data is well known to the model as it is
used to train the model, whereas testing data is like
unseen/new data to the model.
35
Evaluation Metrics
• Performance metrics are used to evaluate the
performance/ effectiveness of our machine learning
model.
36
Performance Metrics for
Regression
• Regression analysis is a subfield of supervised
machine learning.
• It aims to model the relationship between a certain
number of features and a continuous target variable.
• Following are the performance metrics used for
evaluating a regression model:
• Mean Absolute Error (MAE)
• Mean Squared Error (MSE)
• Root Mean Squared Error (RMSE)
• R-Squared
• Adjusted R-squared
37
Mean Squared Error (MSE)
39
Root Mean Squared Error
(RMSE)
40
R-Squared
43
• To understand different metrics, we must
understand the Confusion matrix.
• A confusion matrix is a table that is often used to
describe the performance of a classification model
(or "classifier") on a set of test data for which the
true values are known.
44
For Multiclass
45
• TN- True negatives (actual 0 predicted 0)
• TP- True positives (actual 1 predicted 1)
• FP- False positives (actual 0 predicted 1)
• FN- False Negatives (actual 1 predicted 0)
• Consider the following values for the confusion
matrix-
• True negatives (TN) = 300
• True positives (TP) = 500
• False negatives (FN) = 150
• False positives (FP) = 50
46
Accuracy
48
Recall
49
Precision
50
Specificity
• Specificity is defined as the ratio of True negatives
and True negatives + False positives.
• We want the value of specificity to be high. Its
value lies between [0,1].
52
AUC-ROC
• AUC (Area Under The Curve)- ROC (Receiver
Operating Characteristics) curve is one of the most
important evaluation metrics for checking any
classification model’s performance.
• It is plotted between FPR (X-axis) and TPR (Y-axis).
• If the value is less than 0.5 than the model is even worse
than a random guessing model.
53
54