P3: Key Concepts in Hyperparameter Tuning and Neural Networks

Hyperparameter Tuning
  • Hyperparameter tuning is the systematic adjustment of parameters in a model to optimize performance.
  • It involves changing parameters from simple to complex or vice versa.
    • Example: In regression, transitioning from a cubic polynomial (degree 3) to a nonic (degree 9) and vice-versa.
    • In neural networks, increasing layers from 2 to 4 or neurons per layer from 5 to 6.
  • This tuning must be systematic, as it can greatly influence model performance.
Approaches to Model Complexity
  • Starting with somewhat complex models is recommended.
  • If the model is overfitting (too complex) or underfitting (too simple), adjustments need to be made.
  • Regularization methods should be applied to manage complexity.
    • If the validation error exceeds training error by more than 20%, the model is likely too complex and needs simplification.
  • Techniques for regularization include:
    • Dropouts
    • Batch Normalization
    • L1/Lasso regression.
Understanding Overfitting and Underfitting
  • Overfitting occurs when a model performs well on training data but poorly on unseen data (validation).
  • Underfitting occurs when a model fails to capture the underlying trend of the data.
  • The gap between training set and validation set performance is crucial to monitor:
    • If the gap is above 20%, simplify the model.
    • If below 20%, use regularization or activation function modifications.
Neural Network Basics
Single Layer Perceptron (SLP)
  • The simplest type of neural network with one output neuron and no hidden layers.
  • Structure: Input layer with features (x1, x2, …) that connect to an output layer (y).
    • Bias term included in calculations.
  • Critical rules for SLP:
    1. Number of input neurons should equal the number of features in the dataset.
    2. Number of output neurons should correspond to the number of classes in the output variable (y).
    3. For binary classification, you can model with either one or two output neurons.
    4. The error function used depends on the classification type (binary or multi-category):
    • Binary classification: Use Sigmoid activation function and Binary Cross Entropy loss.
    • Multi-class classification: Use Softmax activation function and Cross Entropy loss.
    1. For regression tasks, use one output neuron with a linear activation function and calculate errors with Mean Squared Error (MSE) or Mean Absolute Error (MAE).
Activation Functions and Error Functions
  • Key activation functions:
    • Sigmoid Function: Suitable for binary classification tasks.
    • Softmax Function: Used for multi-class classification tasks to transform outputs into probability distributions.
  • The choice of error function should match the model type (binary or multi-class):
    • Softmax activation with Multi-category Cross-Entropy for multiple classes.
    • Sigmoid activation with Binary Cross Entropy for binary classification.
  • Important to remember that adjustments to activation functions require corresponding changes in error computation to ensure model performance.