Unit 3
Unit 3
" The goal of hyperparameter tuning is to find the values that lead
to the best performance on a given task.
HYPERPARAMETER TUNING
TECHNIQUES
Models can have many hyperparameters and finding the best
combination of parameters can be treated as a search problem.
The two best strategies for Hyperparameter tuning are:
" GridSearchCV
Randomized SearchCV
Bayesian Optimization
GRIDSEARCHCV
" As in the image, for C= [0.1, 0.2, 0.3, 0.4, 0.5] and Alpha = [0.1,
0.2,0.3, 0.4]. For a combination of C-0.3 and Alpha=0.2, the
performance Highest), therefore it
0.701 0.703 0.697 0.696
is selected. 0.699 0.702 0.698 0.702
0.721 0.726 0.713 0.703
0.706 0.705 0.704 0.701
C0.1 0.698 0.692 0.688 0.675
0.1 0.2 0.3
Alpha
-RandomizedSearchCV
The random search method selects values at random as
opposed to the grid search method's use of a predetermined set
of numbers.
Bayesian Optimization
Grid search and random search are often inefficient because
they evaluate many unsuitable hyperparameter combinations
without considering the previous iterations' results.
Bayesian optimization, on the other hand, treats the search for
optimal hyperparameters as an optimization problem.
" It considers the previous evaluation results when selecting the
next hyperparameter combination and applies a probabilistic
function to choose the combination that will likely yield the best
results.
P(score(y) |hyperparameters(*))
The Bayesian optimization model is complex to implement, but
offthe-shelf libraries like Ray Tune can simplify the process.
" It's worth using this type of model because it finds an adequate
hyperparameter combination in relatively few iterations.
Advantages of Hyperparameter tuning:
" Improved model performance
" Reduced overfitting and underfitting
" Enhanced model generalizability
Optimized resource utilization
" Improved model interpretability
Disadvantages of Hyperparameter tuning:
Computational cost
" Time-consuming process
" Risk of overfitting
" No guarantee of optimal performance
" Requires expertise
" Data Augmentation
Data Augmentation is a technique used in Neural Networks to
artificially increase the size of the training dataset by applying
transformations to existing data.
This helps in reducing overfitting, improving generalization, and
enhancing model robustness.
Example:
" In self-driving cars, road signs may appear in different lighting
conditions, angles, and weather conditions. Augmenting training
images helps the model recognize signs in all possible scenarios.
Augmenting data with noise, contrast changes, and rotations ensures
it learns to detect diseases consistently.
How it works
Data augmentation makes
small changes to the
original data, such as
rotating, flipping, or
adjusting the color
" These changes increase the
Enlarge your Dat diversity of the training set
" The model is exposed to a
broader range of scenarios
which helps it generalize
better
Benefts
Prevents overfitting: Data augmentation helps prevent overfitting. which is when a model performs
well on training data but not on unseen data
Improves model accuracy: Data augmentation can help improve the accuracy of predictions
Reduces operational costs: Data augmentation can reduce the time and expense of data collection and labeling
Causes of Underfitting:
overfitting
" Reduce model complexity.
Early stopping