8000 DOC fix labels in legend of plot_logistic example (#24455) · thomasjpfan/scikit-learn@1645a8a · GitHub
[go: up one dir, main page]

Skip to content

Commit 1645a8a

Browse files
authored
DOC fix labels in legend of plot_logistic example (scikit-learn#24455)
1 parent c21ea70 commit 1645a8a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

examples/linear_model/plot_logistic.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
# Code source: Gael Varoquaux
1414
# License: BSD 3 clause
1515

16-
import numpy as np
1716
import matplotlib.pyplot as plt
18-
19-
from sklearn.linear_model import LogisticRegression, LinearRegression
17+
import numpy as np
2018
from scipy.special import expit
19+
from sklearn.linear_model import LinearRegression, LogisticRegression
2120

2221
# Generate a toy dataset, it's just a straight line with some Gaussian noise:
2322
xmin, xmax = -5, 5
@@ -37,15 +36,20 @@
3736
# and plot the result
3837
plt.figure(1, figsize=(4, 3))
3938
plt.clf()
40-
plt.scatter(X.ravel(), y, color="black", zorder=20)
39+
plt.scatter(X.ravel(), y, label="example data", color="black", zorder=20)
4140
X_test = np.linspace(-5, 10, 300)
4241

4342
loss = expit(X_test * clf.coef_ + clf.intercept_).ravel()
44-
plt.plot(X_test, loss, color="red", linewidth=3)
43+
plt.plot(X_test, loss, label="Logistic Regression Model", color="red", linewidth=3)
4544

4645
ols = LinearRegression()
4746
ols.fit(X, y)
48-
plt.plot(X_test, ols.coef_ * X_test + ols.intercept_, linewidth=1)
47+
plt.plot(
48+
X_test,
49+
ols.coef_ * X_test + ols.intercept_,
50+
label="Linear Regression Model",
51+
linewidth=1,
52+
)
4953
plt.axhline(0.5, color=".5")
5054

5155
plt.ylabel("y")
@@ -55,7 +59,6 @@
5559
plt.ylim(-0.25, 1.25)
5660
plt.xlim(-4, 10)
5761
plt.legend(
58-
("Logistic Regression Model", "Linear Regression Model"),
5962
loc="lower right",
6063
fontsize="small",
6164
)

0 commit comments

Comments
 (0)
0