What is the Pytorch “Module” submodule, and how is it used?
Setup:
1. Creates a class that inherits from torch.nn.Module
2. Define the __init__() method (for layers/submodules & setting up the architecture)
3. Define the forward() method (to specify the flow through the architecture)
4. Create an instance of your class and apply it to input
Examples for gradient-based Optimizers (in Pytorch)
Loss function for regression tasks
MSE (Mean Squared Error)
typically, no output activation function
Loss function for classification tasks
Cross Entropy
sigmoid or log-softmax activation function
What is Regularization and what are common examples?
Methods to counter overfitting
What is a Confusion Matrix?
A table summarizing classification results: True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN).
Define False Positive (FP).
Samples wrongly classified as positive (false alarm, Type I error).
Define False Negative (FN).
Samples wrongly classified as negative (miss, Type II error).
Formula for True Positive Rate (TPR) = Recall = Sensitivity.
“How many true cases did I find?”
TPR = TP / (TP + FN)
Formula for True Negative Rate (TNR) = Specificity
“How well do I reject negatives?”
TNR = TN / (TN + FP)
Formula for False Negative Rate (FNR).
FNR = FN / (FN + TP) = 1 - TPR.
Formula for False Positive Rate (FPR).
FPR = FP / (FP + TN) = 1 - TNR.
Formula for Accuracy (ACC).
overall correctness (misleading if imbalanced)
ACC = (TP + TN) / (TP + TN + FP + FN).
Formula for Balanced Accuracy (BACC).
BACC = (TPR + TNR) / 2;
average of TPR & TNR (good for imbalance)
What is ROC and AUC?
ROC curve shows TPR vs FPR across thresholds; AUC is the area under ROC (0.5 random, 1 perfect).
Formula for Positive Predictive Value (Precision).
“How precise are my alarms?”
PPV = TP / (TP + FP).
Formula for F1-score.
harmonic mean of Precision & Recall (balance them)
F1 = 2 * (Precision * Recall) / (Precision + Recall) = 2TP / (2TP + FP + FN).
Formula for Fβ-score.
Fβ = (1 + β²) * (Precision * Recall) / (β² * Precision + Recall).
Formula for Mean Absolute Error (MAE).
MAE = (Σ|y - ŷ|) / n.
Formula for Mean Squared Error (MSE).
MSE = (Σ(y - ŷ)²) / n.
Formula for Root Mean Squared Error (RMSE).
RMSE = sqrt(MSE).
What does MSE emphasize?
It exaggerates the presence of outliers.
What is a Hold-Out Test Set?
Split dataset into train, validation, and test sets; test set provides independent performance estimate.
What is Cross Validation (CV)?
Split data into n folds; train n times leaving one fold out each time; average validation risk to estimate generalization.