Lecture04
Lecture04
Machine Learning
04
Sensitivity = TP / TP+FN
Sensitivity = (True Positive/True Positive + False Negative)
Sensitivity or Recall 51
Specificity = TN / TN+FP
Specificity = (True Negative)/(True Negative + False Positive)
Specificity 51
• The sum of specificity (true negative rate) and false positive rate
would always be 1. High specificity means that the model is correctly
identifying most of the negative results, while a low specificity means
that the model is mislabeling a lot of negative results as positive.
Sensitivity vs Specificity 51
Accuracy = TP + TN / TP+TN+FP+FN
Precision 51
Precision = TP / TP+FP
F1 score 51
• Replace missing values with the mean, median, or mode of the relevant variable.
• Normalizing Data
Normalization in machine learning is the process of translating data into
the range [0, 1] (or any other range).
• Feature Construction or Generation
Feature Generation (also known as feature construction, feature
extraction or feature engineering) is the process of transforming features
into new features that better relate to the target. This can involve
mapping a feature into a new feature using a function like log, or
creating a new feature from one or multiple features using multiplication
or addition.
Feature Scaling 56
Normalization
Min-max normalization: Guarantees all features will have the exact same scale but does
not handle outliers well.
Z-score standardization: Handles outliers, but does not produce normalized data with the
exact same scale.
Training, Testing and Validation Sets 57
Training, Testing and Validation Set 58
K-Fold Cross Validation 59
K-fold cross-validation is a
technique for evaluating
predictive models.
• Overfitting occurs when the model fits the training data too well and does not
Overfitting generalize so it performs badly on the test data.
• Its the result of an excessively complic ated model.
• Underfitting occurs when the model does not fit the data well enough.
Underfitting • Is result of an excessively simple model.
Under-fitting and Over-fitting 62
About Python
Notebook Pandas
Qtconsole Scipy
Orange Matplotlib
Vscode Sklearn
PyCharm Numpy
Python Exercises to solve this week 66
• https://pynative.com/python-exercises-with-solutions/
• https://www.w3resource.com/machine-learning/scikit-learn/iris/index.php
• https://www.practicepython.org/
Reading Task for this week