Machine Learning with PyTorch and Scikit-Learn
-- Code Examples
Package version checks
Add folder to path in order to load from the check_packages.py script:
Check recommended package versions:
Chapter 6 - Learning Best Practices for Model Evaluation and Hyperparameter Tuning
Overview
Streamlining workflows with pipelines
...
Loading the Breast Cancer Wisconsin dataset
Combining transformers and estimators in a pipeline
Using k-fold cross validation to assess model performance
...
The holdout method
K-fold cross-validation
Debugging algorithms with learning curves
Diagnosing bias and variance problems with learning curves
Addressing over- and underfitting with validation curves
Fine-tuning machine learning models via grid search
Tuning hyperparameters via grid search
Exploring hyperparameter configurations more widely with randomized search
More resource-efficient hyperparameter search with successive halving
Algorithm selection with nested cross-validation
Looking at different performance evaluation metrics
...
Reading a confusion matrix
Additional Note
Remember that we previously encoded the class labels so that malignant examples are the "postive" class (1), and benign examples are the "negative" class (0):
Next, we printed the confusion matrix like so:
Note that the (true) class 0 examples that are correctly predicted as class 0 (true negatives) are now in the upper left corner of the matrix (index 0, 0). In order to change the ordering so that the true negatives are in the lower right corner (index 1,1) and the true positves are in the upper left, we can use the labels
argument like shown below:
We conclude:
Assuming that class 1 (malignant) is the positive class in this example, our model correctly classified 71 of the examples that belong to class 0 (true negatives) and 40 examples that belong to class 1 (true positives), respectively. However, our model also incorrectly misclassified 1 example from class 0 as class 1 (false positive), and it predicted that 2 examples are benign although it is a malignant tumor (false negatives).
Optimizing the precision and recall of a classification model
Plotting a receiver operating characteristic
The scoring metrics for multiclass classification
Dealing with class imbalance
Summary
...
Readers may ignore the next cell.