Skip to content

Commit 1d5e692

Browse files
dhyeyinfDhyey Findoriya
andauthored
DOC: Improve Ridge regression example — fix typo, clarify title, add legend (scikit-learn#31539)
Co-authored-by: Dhyey Findoriya <dhyeyinf323@gmail.com>
1 parent ec1be32 commit 1d5e692

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/linear_model/plot_ridge_path.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
squared loss function and the coefficients tend to zero.
2323
At the end of the path, as alpha tends toward zero
2424
and the solution tends towards the ordinary least squares, coefficients
25-
exhibit big oscillations. In practise it is necessary to tune alpha
25+
exhibit big oscillations. In practice it is necessary to tune alpha
2626
in such a way that a balance is maintained between both.
2727
2828
"""
@@ -63,6 +63,9 @@
6363
ax.set_xlim(ax.get_xlim()[::-1]) # reverse axis
6464
plt.xlabel("alpha")
6565
plt.ylabel("weights")
66-
plt.title("Ridge coefficients as a function of the regularization")
66+
plt.title("Ridge Coefficients vs Regularization Strength (alpha)")
6767
plt.axis("tight")
68+
plt.legend(
69+
[f"Feature {i + 1}" for i in range(X.shape[1])], loc="best", fontsize="small"
70+
)
6871
plt.show()

0 commit comments

Comments
 (0)