Need help with this code

Hello Team
I wanted to know what does ,,hist mean in the below -

,,hist = run_gradient_descent(X_train, y_train, 10, alpha = 1e-7)

Look forward thank you

Please share a screenshot if it is from a code cell which is not graded.

hist usually is plot histogram



Two questions-1) what do we have two dashes before hist what does that mean 2) In the second graph on the right why does it show w only and not other variable where in the code have we specified that ?

Hello @Jasmine7,

If you check out the lab_utils_multi.py scipt file, there you will find the definition for run_gradient_descent(...) which returns a tuple of 3 variables. _ is the variable name usually used to “receive variable” that we do not need in the rest of the code. So, the two _ means that we didn’t need the first two returning variables.

hist, by its name, should mean something’s history, and here I suppose it was the history of cost values, but you can verify it by inspecting the result of print(hist).

As for the graph, it’s just an example and it suffices to demo what the lab wanted to show. We could have chosen either of w1, w2, w3, or b. However, we couldn’t display all of them at the same time because there will be too many dimensions to show in one graph.

Cheers,
Raymond

1 Like

Thanks so much.

1 Like

You are welcome, @Jasmine7!

For more details

The left plot is showing the behavior of the cost across all iterations, while updating all four parameters w[0], w[1], w[2] and w[3] simultaneously.

The right plot :

the blue curve representing the behavior of the cost when we update the weight w[0] (the most impactful weight) alone, while leaving out all the other weights at fixed values.

the orange graph represents the behavior of the cost vs. w[0], when we update all parameters simultaneously. We could’ve replaced w[0] with any other parameter here, but the focus here is on weight of the size w[0].

Updating only w[0] while keeping the other weights fixed produces a nearly similar impact on the cost as updating all four weights together.
This show the strong influence of w[0] (the weight of the size feature) on the overall cost function.

1 Like