To choose a learning rate, run gradient descent with a few candidate values and plot the cost against the number of iterations. Keep the largest value where the cost goes down steadily on every iteration. Feature engineering means using what you know about the problem to scale, transform or combine raw inputs into features the model can learn from more easily.
That’s the short version of Day 8 in my Supervised Machine Learning journey. Today I worked through “Choosing the learning rate,” reviewed the Jupyter lab and learned what feature engineering is. Notes below.
Choosing the learning rate
The most useful tool from this lesson is a simple graph called the learning curve: the cost J on the vertical axis and the number of gradient descent iterations on the horizontal axis. It’s the first thing I’ll look at when a model isn’t training the way I expect.

Reading the learning curve
| What the curve does | What it usually means | What to try |
|---|---|---|
| Cost drops on every iteration, then flattens | Learning rate is working; gradient descent is converging | Keep it, or try a slightly larger value to converge faster |
| Cost drops very slowly | Learning rate is too small | Increase it |
| Cost goes up, or bounces up and down | Learning rate is too large, or there’s a bug in the code | Decrease it; if that doesn’t help, check the code |
A debugging trick
With a small enough learning rate, the cost should decrease on every single iteration. So if you set the learning rate to a very small value and the cost still goes up, the problem is almost certainly a bug, such as a wrong sign in the update step. Don’t train for real with that tiny value, though, because it’s far too slow.
Values to try
Don’t guess one number. Try a range of values, each roughly three times the last:
- 0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 1
Run a handful of iterations for each, plot the learning curves, and pick the largest value that still decreases the cost reliably. A value just below that is often a safe choice.
Feature scaling: why it matters for gradient descent
When I first started Andrew Ng’s Supervised Machine Learning course, I didn’t realize how much of an impact the shape of the data could have on training. But boy, was I in for a surprise!
Andrew Ng uses linear regression to show it. Take two features for predicting a house price: the size of the house in square feet and the number of bedrooms. Size might be in the thousands, while bedrooms range from about 1 to 5.
When features sit on such different scales, gradient descent struggles. The cost surface becomes long and narrow, so the updates zig-zag back and forth instead of heading straight to the minimum. Training then takes much longer, or needs a very small learning rate to stay stable. After scaling, the features cover similar ranges, and gradient descent can take a more direct path.
I struggled with this idea at first. Once it clicked, scaling made a big difference in getting the algorithm to run efficiently.
Common ways to scale a feature:
| Method | How it works | Result |
|---|---|---|
| Divide by the maximum | x / max(x) | Values between 0 and 1 (for positive data) |
| Mean normalization | (x − mean) / (max − min) | Values centred around 0, roughly −1 to 1 |
| Z-score normalization | (x − mean) / standard deviation | Mean 0, standard deviation 1 |
A rough goal is to get each feature into a range around −1 to 1. It doesn’t have to be exact. It just shouldn’t be wildly bigger or smaller than the others.
Feature engineering
Feature engineering is about making your data more useful for a learning algorithm. Think of it like preparing ingredients for a recipe: the better the ingredients, the better the dish. Raw data is rarely good enough on its own. It usually needs to be cleaned, scaled and transformed before the model can find the pattern.
The key takeaway from this part of the course is that you need to understand your data. Feature engineering isn’t only about applying transformations. It’s about using your knowledge of the problem to make the inputs more relevant. Some examples:
- Combine features. With the size of a house and the number of bedrooms, you could create “bedrooms per square foot.” Or, if you have a lot’s frontage and depth, multiply them to get its area, which may predict price better than either one alone.
- Transform features. Adding powers of a feature (x², x³) lets linear regression fit a curve instead of a straight line. That’s polynomial regression. Feature scaling matters even more here, because x³ grows much faster than x.
Later on, these ideas carry over to more complex models like logistic regression and neural networks. The goal is the same: create features that make it easier for the algorithm to find patterns and make predictions.
To be honest, I didn’t expect feature engineering to make such a difference. Once I practised it, though, I saw how tweaking and transforming features could lead to better results. It felt like unlocking a new level in the course: instead of just feeding data into the algorithm, I was working with it to make the algorithm smarter. It turned out to be one of the most rewarding parts of learning machine learning so far, and it’s something I’ll keep honing.
The end of this learning week?!
I didn’t expect to reach the end of this learning week already! I didn’t spend much time on the labs. There are three labs this week, and I’m not sure I’m ready for the practice lab yet. That’s my next step.
The journey continues with gradient descent and binary classification in Day 9. Thanks for reading!
FAQ
How do I know if my learning rate is too high? Plot the cost against the number of iterations. If the cost increases or jumps up and down instead of falling steadily, the learning rate is probably too high. Reduce it and check again.
What learning rate should I start with? There’s no single right value. Try a range such as 0.001, 0.003, 0.01, 0.03, 0.1, 0.3 and 1. Then pick the largest one where the cost still decreases on every iteration.
Is feature scaling the same as feature engineering? Scaling is one part of it. Feature engineering covers any way of preparing inputs: scaling, transforming (for example adding x²) or combining features (for example frontage × depth = area).
Why does feature scaling make gradient descent faster? Features on very different scales make the cost surface long and narrow, so gradient descent zig-zags toward the minimum. Scaled features give it a more direct path, so it needs fewer iterations.