Skip to content

Commit 33ed031

Browse files
committed
Pushing the docs to dev/ for branch: master, commit f65cdf2d5e5f2b753393190598f9c9f63f34dbe1
1 parent 56ff808 commit 33ed031

File tree

1,206 files changed

+4123
-4124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,206 files changed

+4123
-4124
lines changed
Binary file not shown.

dev/_downloads/998b4a46568dd85981260617d1ad84f5/plot_logistic_path.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
coefficients are exactly 0. When regularization gets progressively looser,
1515
coefficients can get non-zero values one after the other.
1616
17-
Here we choose the SAGA solver because it can efficiently optimize for the
17+
Here we choose the liblinear solver because it can efficiently optimize for the
1818
Logistic Regression loss with a non-smooth, sparsity inducing l1 penalty.
1919
2020
Also note that we set a low value for the tolerance to make sure that the model
@@ -55,9 +55,10 @@
5555

5656
print("Computing regularization path ...")
5757
start = time()
58-
clf = linear_model.LogisticRegression(penalty='l1', solver='saga',
58+
clf = linear_model.LogisticRegression(penalty='l1', solver='liblinear',
5959
tol=1e-6, max_iter=int(1e6),
60-
warm_start=True)
60+
warm_start=True,
61+
intercept_scaling=10000.)
6162
coefs_ = []
6263
for c in cs:
6364
clf.set_params(C=c)

dev/_downloads/ae49c1224c84d28b4dc12e3acba54a04/plot_logistic_path.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Regularization path of L1- Logistic Regression\n\n\n\nTrain l1-penalized logistic regression models on a binary classification\nproblem derived from the Iris dataset.\n\nThe models are ordered from strongest regularized to least regularized. The 4\ncoefficients of the models are collected and plotted as a \"regularization\npath\": on the left-hand side of the figure (strong regularizers), all the\ncoefficients are exactly 0. When regularization gets progressively looser,\ncoefficients can get non-zero values one after the other.\n\nHere we choose the SAGA solver because it can efficiently optimize for the\nLogistic Regression loss with a non-smooth, sparsity inducing l1 penalty.\n\nAlso note that we set a low value for the tolerance to make sure that the model\nhas converged before collecting the coefficients.\n\nWe also use warm_start=True which means that the coefficients of the models are\nreused to initialize the next model fit to speed-up the computation of the\nfull-path.\n"
18+
"\n# Regularization path of L1- Logistic Regression\n\n\n\nTrain l1-penalized logistic regression models on a binary classification\nproblem derived from the Iris dataset.\n\nThe models are ordered from strongest regularized to least regularized. The 4\ncoefficients of the models are collected and plotted as a \"regularization\npath\": on the left-hand side of the figure (strong regularizers), all the\ncoefficients are exactly 0. When regularization gets progressively looser,\ncoefficients can get non-zero values one after the other.\n\nHere we choose the liblinear solver because it can efficiently optimize for the\nLogistic Regression loss with a non-smooth, sparsity inducing l1 penalty.\n\nAlso note that we set a low value for the tolerance to make sure that the model\nhas converged before collecting the coefficients.\n\nWe also use warm_start=True which means that the coefficients of the models are\nreused to initialize the next model fit to speed-up the computation of the\nfull-path.\n"
1919
]
2020
},
2121
{
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"print(__doc__)\n\n# Author: Alexandre Gramfort <[email protected]>\n# License: BSD 3 clause\n\nfrom time import time\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn import linear_model\nfrom sklearn import datasets\nfrom sklearn.svm import l1_min_c\n\niris = datasets.load_iris()\nX = iris.data\ny = iris.target\n\nX = X[y != 2]\ny = y[y != 2]\n\nX /= X.max() # Normalize X to speed-up convergence\n\n# #############################################################################\n# Demo path functions\n\ncs = l1_min_c(X, y, loss='log') * np.logspace(0, 7, 16)\n\n\nprint(\"Computing regularization path ...\")\nstart = time()\nclf = linear_model.LogisticRegression(penalty='l1', solver='saga',\n tol=1e-6, max_iter=int(1e6),\n warm_start=True)\ncoefs_ = []\nfor c in cs:\n clf.set_params(C=c)\n clf.fit(X, y)\n coefs_.append(clf.coef_.ravel().copy())\nprint(\"This took %0.3fs\" % (time() - start))\n\ncoefs_ = np.array(coefs_)\nplt.plot(np.log10(cs), coefs_, marker='o')\nymin, ymax = plt.ylim()\nplt.xlabel('log(C)')\nplt.ylabel('Coefficients')\nplt.title('Logistic Regression Path')\nplt.axis('tight')\nplt.show()"
29+
"print(__doc__)\n\n# Author: Alexandre Gramfort <[email protected]>\n# License: BSD 3 clause\n\nfrom time import time\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn import linear_model\nfrom sklearn import datasets\nfrom sklearn.svm import l1_min_c\n\niris = datasets.load_iris()\nX = iris.data\ny = iris.target\n\nX = X[y != 2]\ny = y[y != 2]\n\nX /= X.max() # Normalize X to speed-up convergence\n\n# #############################################################################\n# Demo path functions\n\ncs = l1_min_c(X, y, loss='log') * np.logspace(0, 7, 16)\n\n\nprint(\"Computing regularization path ...\")\nstart = time()\nclf = linear_model.LogisticRegression(penalty='l1', solver='liblinear',\n tol=1e-6, max_iter=int(1e6),\n warm_start=True,\n intercept_scaling=10000.)\ncoefs_ = []\nfor c in cs:\n clf.set_params(C=c)\n clf.fit(X, y)\n coefs_.append(clf.coef_.ravel().copy())\nprint(\"This took %0.3fs\" % (time() - start))\n\ncoefs_ = np.array(coefs_)\nplt.plot(np.log10(cs), coefs_, marker='o')\nymin, ymax = plt.ylim()\nplt.xlabel('log(C)')\nplt.ylabel('Coefficients')\nplt.title('Logistic Regression Path')\nplt.axis('tight')\nplt.show()"
3030
]
3131
}
3232
],
Binary file not shown.

dev/_downloads/scikit-learn-docs.pdf

-3.33 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes
98 Bytes
98 Bytes
107 Bytes
107 Bytes

0 commit comments

Comments
 (0)