Corfficient

What do you mean by coef_[0] i don’t understand why coef came with index 0 (well that’s i interprets it). Also must it always be 0, can it be change to 1 or any other values)

linear_regression.coef_ will be an array of (n_features,). Since we have a single feature, we would have an array of shape (1,). Then we just get the first value of the by indexing.

If we would have several features, then we could get the value of any individual feature.

Okay, i understand but what if we had a feature of 7. How do we do it? Will linear_regression.coef_[1] still do the work? Or should it be linear_regression.coef_[7][1]

If you have 7 features, then coef_ will be a NumPy array of dimensions (7,). Then you can use any index between 0 and 6 to get the value of the coefficients that you want and you will index it as linear_regression.coef_[i] where i is between 0 and 6.

1 Like

Awesome. Thank You