More explanation on intercept_ and coef_

So, I noticed that the weight and coef_ were two different things. The documentation of linear regression says that give y = wx + b, w is a wighted parameter and b is the intercept. So, is (w) coef_ and (b) intercept_.

Please the team should kindly clarify this. My sincere apprecaition.

weight and coef_ are same thing…
as model.coef_ give the respective weights of each column and model.intercept_ gives the bias…

Yes (w) is coef_ (more precisely w’s are coef_)…and (b) is intercept_

Hello, there!
Let us consider the basic equation of the straight line. If the line travels through the origin ie (0, 0), the equation of the straight line is, simply y = mx.
Now, the symbol m describes how much the straight line is inclined with the x-axis. If m = 0, it means, the equation is,
y = 0. If m = 1, it means that the equation is, y = x, ie it is inclined at an angle of 45 degrees to the x-axis.
So, all straight lines parallel to the line y = x, will have an equation, y = mx + c. In Pure Mathematics, we call this c, ‘the intercept’ ie the value of the length of the line crossing the y-axis.


When we learn a name, it is best if we learn all the names it may be called by.

Quiz_1. How many models do have a zero bias?
Quiz_2. What is the equation of the green model passing through the Origin?
Quiz_3. What is the equation of the blue model passing through the Origin?
Quiz_4. What is the equation of the black model passing through the Origin?
Quiz_5. What is the equation of the purple model passing through the Origin?
Quiz_6. What is the equation of the line parallel to the black model?
Quiz_7. What is the bias of the model parallel to the black model passing through (0, 0)?
Quiz_8. What is the bias of the model parallel to the black model passing through (0, 0)?
I hope to get back as soon as I could allow myself enough time to answer these questions. In the meantime, I shall leave it to the questioner to sort it out themselves.
Best of luck, my friends.

2 Likes

Quiz_1. Answer. Five models in the image have zero bias.
Quiz_2. Answer. The equation of the green model is y = 0.5x.
Quiz_3. Answer. The equation of the blue model is y = x.
Quiz_4. Answer. The equation of the black model is y = 2x.
Quiz_5. Answer. The equation of the purple model is y = 4x.
Quiz_6. Answer. The equation of the model parallel to the black model is y = 2x + 2.
Quiz_7. Answer. The bias of the model parallel to the black model passing through a point (0, 3 ) is 3; b = 3.
Quiz_8. Answer. The bias of the model parallel to the black model passing through a point (0, 4 ) is 4; b = 4.
|| corrigenda ||
There are two typos in my first set of questions, Q#7 and Q#8. They should be (0, 3) and (0, 4) respectively.
I should like to edit them, if possible.
<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>
Explanation and insight:
///////////////////////////////////////////////////////////////////////////////
We have shown five models going through the Origin, (0, 0) and they are (i) red, (ii) green, (iii) blue, (iv) black, and (v) purple.

(i) The red line is lying flat coincident with the x-axis. It goes through (0, 0), it means b = 0, it is coincident with the x-axis, it means m = 0. Therefore, the equation of the red model is y=0 (y = 0 times x + 0 = 0)
Another way of looking at it is, all y-values on the x-axis is 0, there the equation of the x-axis is 0.

(ii) The green model has a positive slope. When we are dealing with such a model, y has a positive correlation with x.

As x increases, y increases. If we are asked, at what rate is y increasing with respect to x, immediately we start looking for the slope to answer this question.

What is the slope? The slope is the tangent, the dy/dx, the coefficient (coef_), aka m. What is m here; how do we find m from the graph? We say, ‘rise over run’. rise is the y-value, run is the x-value? m (== 1/2 == 2/4 == 3/6) from the graph.
((aka == also known as))

Since m=0.5, the green model may be represented by the equation, y = 0.5x (with no bias, as b = 0)

(iii) The next model is the blue model. Its slope, m is 1. (2/2 == 4/4). So the model may be represented by the equation, y = x (with no bias, as b = 0)

(iv) The black model is the next model the slope of which is 2 (4/2); 4 is the rise; 2 is the run. So the black model may be represented by the equation, y = 2x (with no bias, as b = 0)

(v) The fifth model is the purple model the slope of which is 4 (4/1); 4 is the rise; 1 is the run. So the purple model may be represented by the equation, y = 4x (with no bias, as b = 0)

(vi) The sixth model is the second black model parallel to the first black model. How do we know it is parallel to the first black model? The answer is very simple. Its slope is 2. (4 small squares / 2 small squares) rise is 4 small squares; run is 2 small squares. What is the bias of this model? This is the only model the bias of which is not 0; its bias is 2; bias, b = 2. So what is its equation? We know both m and b; so its equation is y = 2x + 2

NB. It would be a good idea if there is provision for subsequent EDITs. To err is human. There should be room for improvement.

3 Likes

Hey…
First of all thank you for such a nice post…
So, you can edit your questions and answers by clicking on the Pencil Icon present on the left of Reply Button

@vinaypratapsingh609
Thanks for the compliments; I feel obligatory on my part to stretch helping hands. That’s why we are humans, don’t you think?

Please, help. I couldn’t get the text corrected. The pencil icon, as you suggested, allowed me in but did not allow any corrections to be made.

Could you please help? Could you please help keep the EDIT option LEFT OPEN for me so that I can make corrections whenever I find time? I wouldn’t like to leave typos or EDITS untreated because they may arouse CONFUSION. It breaks the chains of the thought processes of anyone I’m willing to help.
Q#s 7 and 8 need to be (0, 3) and (0, 4) respectively instead of (0, 0) and (0, 0).

Hey…
The Pencil Icon on your post of question…must be appearing right here…between Link Icon and Three Dots

When you click it…you will be able to edit your post and click on Save Edit Button*

Actually I can’t edit or change your post…only the person who has created it can edit it…
I can Copy and past your post with the required changes if you want…