Skip to content

Commit 3c18735

Browse files
Deborah-DiggesTomDLT
authored andcommitted
[MRG+2] logit -> logistic in plot_logistic.py and minor visual improvements to the plot. (scikit-learn#7730)
* Small correction of logit->logistic The function `1 / (1 + np.exp(-x))` is the logistic function. The logit function is the inverse of the logistic function : `log(x/(1-x))` * Add axes ticks, legend and colors to the plot * Fix flake8 errors * Rename legend labels as per review * Fix pep8 error
1 parent 0dfc9a5 commit 3c18735

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

examples/linear_model/plot_logistic.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
"""
66
=========================================================
7-
Logit function
7+
Logistic function
88
=========================================================
99
10-
Show in the plot is how the logistic regression would, in this
10+
Shown in the plot is how the logistic regression would, in this
1111
synthetic dataset, classify values as either 0 or 1,
12-
i.e. class one or two, using the logit-curve.
12+
i.e. class one or two, using the logistic curve.
1313
1414
"""
1515
print(__doc__)
@@ -48,7 +48,7 @@
4848
def model(x):
4949
return 1 / (1 + np.exp(-x))
5050
loss = model(X_test * clf.coef_ + clf.intercept_).ravel()
51-
plt.plot(X_test, loss, color='blue', linewidth=3)
51+
plt.plot(X_test, loss, color='red', linewidth=3)
5252

5353
ols = linear_model.LinearRegression()
5454
ols.fit(X, y)
@@ -57,9 +57,10 @@ def model(x):
5757

5858
plt.ylabel('y')
5959
plt.xlabel('X')
60-
plt.xticks(())
61-
plt.yticks(())
60+
plt.xticks(range(-5, 10))
61+
plt.yticks([0, 0.5, 1])
6262
plt.ylim(-.25, 1.25)
6363
plt.xlim(-4, 10)
64-
64+
plt.legend(('Logistic Regression Model', 'Linear Regression Model'),
65+
loc="lower right", fontsize='small')
6566
plt.show()

0 commit comments

Comments
 (0)