Skip to content

Commit 76eebd1

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 1b20d0ac853251cce6f8309ac4617e960edc1a98
1 parent 48560ab commit 76eebd1

File tree

1,207 files changed

+4001
-3694
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,207 files changed

+4001
-3694
lines changed
Binary file not shown.

dev/_downloads/7ee55c12f8d3eb1dd8d2005d9dd7b6f1/plot_release_highlights_0_22_0.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
To install the latest version (with pip)::
1414
15-
pip install -U scikit-learn --upgrade
15+
pip install --upgrade scikit-learn
1616
1717
or with conda::
1818
@@ -172,3 +172,62 @@
172172
# recomputed.
173173
estimator.set_params(isomap__n_neighbors=5)
174174
estimator.fit(X)
175+
176+
############################################################################
177+
# Stacking Classifier and Regressor
178+
# ---------------------------------
179+
# :class:`~ensemble.StackingClassifier` and
180+
# :class:`~ensemble.StackingRegressor`
181+
# allow you to have a stack of estimators with a final classifier or
182+
# a regressor.
183+
# Stacked generalization consists in stacking the output of individual
184+
# estimators and use a classifier to compute the final prediction. Stacking
185+
# allows to use the strength of each individual estimator by using their output
186+
# as input of a final estimator.
187+
# Base estimators are fitted on the full ``X`` while
188+
# the final estimator is trained using cross-validated predictions of the
189+
# base estimators using ``cross_val_predict``.
190+
#
191+
# Read more in the :ref:`User Guide <stacking>`.
192+
193+
from sklearn.datasets import load_iris
194+
from sklearn.ensemble import RandomForestClassifier
195+
from sklearn.svm import LinearSVC
196+
from sklearn.linear_model import LogisticRegression
197+
from sklearn.preprocessing import StandardScaler
198+
from sklearn.pipeline import make_pipeline
199+
from sklearn.ensemble import StackingClassifier
200+
from sklearn.model_selection import train_test_split
201+
202+
X, y = load_iris(return_X_y=True)
203+
estimators = [
204+
('rf', RandomForestClassifier(n_estimators=10, random_state=42)),
205+
('svr', make_pipeline(StandardScaler(),
206+
LinearSVC(random_state=42)))
207+
]
208+
clf = StackingClassifier(
209+
estimators=estimators, final_estimator=LogisticRegression()
210+
)
211+
X_train, X_test, y_train, y_test = train_test_split(
212+
X, y, stratify=y, random_state=42
213+
)
214+
clf.fit(X_train, y_train).score(X_test, y_test)
215+
216+
############################################################################
217+
# Checking scikit-learn compatibility of an estimator
218+
# ---------------------------------------------------
219+
# Developers can check the compatibility of their scikit-learn compatible
220+
# estimators using :func:`~utils.estimator_checks.check_estimator`. For
221+
# instance, the ``check_estimator(LinearSVC)`` passes.
222+
#
223+
# We now provide a ``pytest`` specific decorator which allows the ``pytest``
224+
# ro run all checks independently and report the checks that are failing.
225+
226+
from sklearn.linear_model import LogisticRegression
227+
from sklearn.tree import DecisionTreeRegressor
228+
from sklearn.utils.estimator_checks import parametrize_with_checks
229+
230+
231+
@parametrize_with_checks([LogisticRegression, DecisionTreeRegressor])
232+
def test_sklearn_compatible_estimator(estimator, check):
233+
check(estimator)

dev/_downloads/c101b602d0b3510ef47dd19d64a4a92b/plot_release_highlights_0_22_0.ipynb

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n========================================\nRelease Highlights for scikit-learn 0.22\n========================================\n\n.. currentmodule:: sklearn\n\nWe are pleased to announce the release of scikit-learn 0.22, which comes\nwith many bug fixes and new features! We detail below a few of the major\nfeatures of this release. For an exhaustive list of all the changes, please\nrefer to the `release notes <changes_0_22>`.\n\nTo install the latest version (with pip)::\n\n pip install -U scikit-learn --upgrade\n\nor with conda::\n\n conda install scikit-learn\n"
18+
"\n========================================\nRelease Highlights for scikit-learn 0.22\n========================================\n\n.. currentmodule:: sklearn\n\nWe are pleased to announce the release of scikit-learn 0.22, which comes\nwith many bug fixes and new features! We detail below a few of the major\nfeatures of this release. For an exhaustive list of all the changes, please\nrefer to the `release notes <changes_0_22>`.\n\nTo install the latest version (with pip)::\n\n pip install --upgrade scikit-learn\n\nor with conda::\n\n conda install scikit-learn\n"
1919
]
2020
},
2121
{
@@ -143,6 +143,42 @@
143143
"source": [
144144
"from tempfile import TemporaryDirectory\nfrom sklearn.neighbors import KNeighborsTransformer\nfrom sklearn.manifold import Isomap\nfrom sklearn.pipeline import make_pipeline\n\nwith TemporaryDirectory(prefix=\"sklearn_cache_\") as tmpdir:\n estimator = make_pipeline(\n KNeighborsTransformer(n_neighbors=10, mode='distance'),\n Isomap(n_neighbors=10, metric='precomputed'),\n memory=tmpdir)\n estimator.fit(X)\n\n # We can decrease the number of neighbors and the graph will not be\n # recomputed.\n estimator.set_params(isomap__n_neighbors=5)\n estimator.fit(X)"
145145
]
146+
},
147+
{
148+
"cell_type": "markdown",
149+
"metadata": {},
150+
"source": [
151+
"Stacking Classifier and Regressor\n---------------------------------\n:class:`~ensemble.StackingClassifier` and\n:class:`~ensemble.StackingRegressor`\nallow you to have a stack of estimators with a final classifier or\na regressor.\nStacked generalization consists in stacking the output of individual\nestimators and use a classifier to compute the final prediction. Stacking\nallows to use the strength of each individual estimator by using their output\nas input of a final estimator.\nBase estimators are fitted on the full ``X`` while\nthe final estimator is trained using cross-validated predictions of the\nbase estimators using ``cross_val_predict``.\n\nRead more in the `User Guide <stacking>`.\n\n"
152+
]
153+
},
154+
{
155+
"cell_type": "code",
156+
"execution_count": null,
157+
"metadata": {
158+
"collapsed": false
159+
},
160+
"outputs": [],
161+
"source": [
162+
"from sklearn.datasets import load_iris\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.svm import LinearSVC\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.ensemble import StackingClassifier\nfrom sklearn.model_selection import train_test_split\n\nX, y = load_iris(return_X_y=True)\nestimators = [\n ('rf', RandomForestClassifier(n_estimators=10, random_state=42)),\n ('svr', make_pipeline(StandardScaler(),\n LinearSVC(random_state=42)))\n]\nclf = StackingClassifier(\n estimators=estimators, final_estimator=LogisticRegression()\n)\nX_train, X_test, y_train, y_test = train_test_split(\n X, y, stratify=y, random_state=42\n)\nclf.fit(X_train, y_train).score(X_test, y_test)"
163+
]
164+
},
165+
{
166+
"cell_type": "markdown",
167+
"metadata": {},
168+
"source": [
169+
"Checking scikit-learn compatibility of an estimator\n---------------------------------------------------\nDevelopers can check the compatibility of their scikit-learn compatible\nestimators using :func:`~utils.estimator_checks.check_estimator`. For\ninstance, the ``check_estimator(LinearSVC)`` passes.\n\nWe now provide a ``pytest`` specific decorator which allows the ``pytest``\nro run all checks independently and report the checks that are failing.\n\n"
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": null,
175+
"metadata": {
176+
"collapsed": false
177+
},
178+
"outputs": [],
179+
"source": [
180+
"from sklearn.linear_model import LogisticRegression\nfrom sklearn.tree import DecisionTreeRegressor\nfrom sklearn.utils.estimator_checks import parametrize_with_checks\n\n\n@parametrize_with_checks([LogisticRegression, DecisionTreeRegressor])\ndef test_sklearn_compatible_estimator(estimator, check):\n check(estimator)"
181+
]
146182
}
147183
],
148184
"metadata": {
Binary file not shown.

dev/_downloads/scikit-learn-docs.pdf

15.5 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes

0 commit comments

Comments
 (0)