Intel Assignment
Intel Assignment
Intel AI For
Manufacturing
Assignment 5
Modelling and
Evaluation
Dhoriwala
Mahammed Tabrez
220140111002
220140111002
• Description:
Measures the average absolute difference between actual and
predicted values. It is simple and easy to interpret.
• When to Use:
• Example:
Used in house price prediction, where small deviations matter
equally.
• Description:
Measures the average squared difference between actual and
predicted values. Penalizes larger errors more than MAE.
• When to Use:
220140111002
• Example:
Used in stock market forecasting, where large errors can have
significant consequences.
• Description:
Similar to MSE but returns error in the same unit as the target
variable, making it easier to interpret.
• When to Use:
o When large errors need to be penalized, but in the same unit
as the original values.
• Example:
Used in weather prediction, where temperature deviations must be
minimized.
• Description:
Measures the percentage error between actual and predicted
values.
• When to Use:
• Example:
Used in sales forecasting, where understanding percentage
deviation is important.
5. R-squared (R²)
• Formula: 𝑅2 = 1 − ∑(𝑦𝑖 − 𝑦^𝑖)2∑(𝑦𝑖 − 𝑦ˉ)2𝑅^2 = 1 −
\𝑓𝑟𝑎𝑐{\𝑠𝑢𝑚 (𝑦_𝑖 − \ℎ𝑎𝑡{𝑦}_𝑖)^2}{\𝑠𝑢𝑚 (𝑦_𝑖 − \𝑏𝑎𝑟{𝑦})^2}
• Description:
Measures the proportion of variance explained by the model.
Values closer to 1 indicate better fit.
• When to Use:
o When needing to assess how well a model explains
variability in the data.
• Example:
Used in econometrics, where understanding explanatory power is
crucial.
6. Adjusted R-squared
• Description:
Similar to R² but adjusts for the number of predictors in the model,
preventing overfitting.
• When to Use:
o When comparing models with different numbers of predictors.
• Example:
Used in medical research to determine how well multiple factors
predict disease progression.
220140111002
7. Huber Loss
• Formula: 𝐿𝛿 ,𝑓𝑜𝑟 , 𝑓𝑜𝑟
𝛿𝐿_{\𝑑𝑒𝑙𝑡𝑎} \𝑏𝑒𝑔𝑖𝑛{𝑐𝑎𝑠𝑒𝑠} \𝑓𝑟𝑎𝑐 ,& \
𝑡𝑒𝑥𝑡 |𝑎| \𝑙𝑒𝑞 \𝑑𝑒𝑙𝑡𝑎 \\ \𝑑𝑒𝑙𝑡𝑎 \𝑓𝑟𝑎𝑐 \𝑑𝑒𝑙𝑡𝑎), & \
𝑡𝑒𝑥𝑡 \𝑑𝑒𝑙𝑡𝑎 \𝑒𝑛𝑑{𝑐𝑎𝑠𝑒𝑠}
• Description:
A combination of MSE (for small errors) and MAE (for large errors),
reducing sensitivity to outliers.
• When to Use:
o Whenthe dataset contains outliers, but they should not
dominate the model.
• Example:
Used in autonomous vehicle trajectory prediction, where sensor
noise can introduce outliers.
8. Log-Cosh Loss
• Formula: \𝑠𝑢𝑚 \𝑙𝑜𝑔 (\𝑐𝑜𝑠ℎ(𝑦_𝑖 −
\
• Description:
Similar to Huber Loss but smoother and less sensitive to large
errors.
• When to Use:
o Whenhandling moderate outliers with smooth loss function
properties.
• Example:
Used in time-series forecasting to minimize impact of occasional
large fluctuations.
220140111002
A 2x2 confusion matrix for a binary classification problem looks like this:
of the model.
1 1 (Spam) 1 (Spam)
4 1 (Spam) 1 (Spam)
6 1 (Spam) 1 (Spam)
Performance Metrics
Interpretation of Results
• Accuracy is 60%, meaning the model correctly classified 6 out of
10 emails.
• Precision is 60%, meaning 60% of emails predicted as spam were
actually spam.
• Recall is 60%, meaning the model identified 60% of all actual
spam emails, but missed 40%.
Python Implementation:-
from sklearn.metrics import confusion_matrix, accuracy_score, precision_score,
recall_score, f1_score
= [1, 0, 1, 1, 0, 1, 0, 1, 0, 0]
y_pred = [1, 0, 0, 1, 1, 1, 0, 0, 0, 1]
220140111002
confusion_matrix(y_true, y_pred) #
accuracy = accuracy_score(y_true,
y_pred) precision =
= recall_score(y_true, y_pred) f1 =
f1_score(y_true, y_pred)
Matrix:") print(cm)
print(f"\nAccuracy: {accuracy:.2f}")
print(f"Precision: {precision:.2f}")
print(f"Recall: {recall:.2f}")