#dailyNote
spam for note testing
more preamble
#meta #todoList
- Complete [[Python]] module
- Complete Bias and Variance
- Note cleanup with Aliases (see [[Career and Study To - Do]])
- [[Linear Algebra]] [[Note Migration]]
- Integrate with this daily note - [ ] [[Training, Test, and Dev Sets]] - [ ] [[regularization]] (#merge and integrate) - [ ] [[Cost and Loss]]
- Big overhaul of [[Bias and Variance]] with regards to todays notes.
These notes will be integrated into other notes but kept here in their entirety.
[[Machine Learning Specialization]] Advanced Machine Learning Algorithms, Week 3
Models almost never work the first time you try them out. Let's see how we can fix them.
See [[Bias and Variance]]
If you have more features, you can't visualize [[Bias and Variance]]
A more systematic way to see if you have high bias or high variance is to look at the performance of the algorithm on the [[Training, Test, and Dev Sets|training set and dev set]]
A characteristic of a High Bias (under-fit) model is that
![[Screenshot 2023-10-17 at 1.26.00 PM.png]]
Take degree of polynomial
![[Screenshot 2023-10-17 at 1.29.21 PM.png]]
How do you tell if your algorithm has a high bias or variance problem?
One key takeaway is that high bias means it is not even doing well on the training set and high variance means it does much worse on the cross validation set and the training set.
In an under-fit model
In an over-fit model
In a model with both high bias and high variance
![[Screenshot 2023-10-17 at 1.38.51 PM.png]]
[[Regularized Linear Regression]] model:
[[Lambda]]
Take this model:
If lambda is large, say
On the other hand, if we set
So, how do we find a good value for
![[Screenshot 2023-10-17 at 3.56.53 PM.png]]
This will be similar to choosing
![[Screenshot 2023-10-17 at 4.15.27 PM.png]]
Cross Validation tries out many versions of
![[Screenshot 2023-10-17 at 4.14.07 PM.png]]
Job is to take in audio and output the text of what a person is saying
Training error
Why is human level error so high? There is lots of noise in the audio. It seems unfair to expect a learning algorithm to do much better.
It is thus is more useful to measure the training error against the human error.
So, looking at these results,
What is the level of error you can reasonably hope to get to?
- Human level performance
- Competing algorithms performance
- Guess based on experience
Gap between baseline and training error shows high bias. A gap between training error and cross validation error shows high variance.
If your goal is perfection, the baseline would be zero. But for a lot of real world examples, like audio recognition, there is a lot of noise in the data, so you need a higher baseline.
If there is a gap between all three is high you have both high bias and high variance.
![[Screenshot 2023-10-17 at 4.42.49 PM.png]]
Noted in [[Learning Curves]]
Learning curves help understand how your learning algorithm is doing as a function of the amount of experience it has. Experience being the number of training examples it has.
The bigger the training set the harder it is to fit all examples perfectly. Thus; as the training set increases so does the training error
Plotting a learning curve by training different models based on different subsets of training data is computationally expensive, so in practice it isn't done that often. But, it's a good mental visualization.
![[Screenshot 2023-10-17 at 5.40.04 PM.png]]
If a learning algorithm suffers from high bias, getting more training data will not (by itself) help that much.
![[Screenshot 2023-10-17 at 5.44.29 PM.png]]
If a learning algorithm suffers from high variance, getting more training data is likely to help.
![[Screenshot 2023-10-17 at 5.49.45 PM.png]]
Get more training examples: fixes high variance
Try smaller set of features: fixes high variance
Try getting additional features: fixes high bias
Examples; an algorithm that lacks information wont even do well on the training set
Adding polynomial features (
Note! Don't randomly throw away training examples just to fix a high bias problem.
#merge with [[Bias and Variance]] ?
If your algorithm has high variance, try simplifying your model or getting more training data. Simplification can mean a smaller set of features or an increased [[regularization]]
If your algorithm has high bias, that is to say its not even doing well on the training set, you mainly need to make your model more powerful and flexible to fit more complex functions. To do so you can give it additional features, add polynomial features, or decrease
Simple model = high bias Complex model = high variance Before neural networks, we had to worry about balancing this complexity between bias and variance. With neural networks we now are mostly worried about high variance.
Large [[Neural Network|neural networks]] are low bias machines. If you make your neural network large enough you can almost always fit your training set well.
- Train a neural network
- If the training set error
$J_{train}(\vec{w},b)$ is high relative to your baseline, increase the size of the neural network by adding hidden layers. - Once
$J_{train}(\vec{w},b)$ is low enough, see if it does well on the cross validation set - If the cross validation set
$J_{cv}(\vec{w},b)$ is too high, add more data, then test again from step 2. - Repeat until
$J_{cv}(\vec{w},b)$ is low enough for your liking.
![[Screenshot 2023-10-17 at 6.38.46 PM.png]]
Bigger networks are restricted by your computing power, data is restricted to the amount of data you have.
Sometimes you will pingpong back between high bias and high variance as you move through this recipe and develop a machine learning algorithm. Use these observations to shape what you do next in the process.
A large neural network will usually do as well or better than a smaller one so long as [[regularization]] is chosen appropriately. Of course, larger neural networks are more computationally expensive.
#function and [[TensorFlow]] implementation: ![[Screenshot 2023-10-17 at 6.46.28 PM.png]]Note usually don't regularize B, it doesn't really affect anything
From [[codecademy]]
- Continue Keyword: used inside a loop to skip the remaining loop code block and begin the next loop iteration.
- Break keyword escapes the loop, regardless of the iteration number. Once break executes the program will continue to execute after the loop.
- List Comprehension
- Run loops within a list:
new_prices=[price - 5 for price in prices]
This is similar to choosing the degree of the polynomial using [[Training, Test, and Dev Sets]]