Skip to content

Commit 06b4d4e

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 309f135c3284d7db6e23ca81a87948c7066a3949
1 parent e501aa5 commit 06b4d4e

File tree

1,273 files changed

+4126
-4159
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,273 files changed

+4126
-4159
lines changed
Binary file not shown.

dev/_downloads/215c560d29193ab9b0a495609bc74802/plot_monotonic_constraints.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from sklearn.experimental import enable_hist_gradient_boosting # noqa\nfrom sklearn.ensemble import HistGradientBoostingRegressor\nfrom sklearn.inspection import plot_partial_dependence\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\nprint(__doc__)\n\nrng = np.random.RandomState(0)\n\nn_samples = 5000\nf_0 = rng.rand(n_samples) # positive correlation with y\nf_1 = rng.rand(n_samples) # negative correlation with y\nX = np.c_[f_0, f_1]\nnoise = rng.normal(loc=0.0, scale=0.01, size=n_samples)\ny = (5 * f_0 + np.sin(10 * np.pi * f_0) -\n 5 * f_1 - np.cos(10 * np.pi * f_1) +\n noise)\n\nfig, ax = plt.subplots()\n\n\n# Without any constraint\ngbdt = HistGradientBoostingRegressor()\ngbdt.fit(X, y)\ndisp = plot_partial_dependence(\n gbdt,\n X,\n features=[0, 1],\n line_kw={\"linewidth\": 4, \"label\": \"unconstrained\", \"color\": \"tab:blue\"},\n ax=ax,\n)\n\n# With positive and negative constraints\ngbdt = HistGradientBoostingRegressor(monotonic_cst=[1, -1])\ngbdt.fit(X, y)\n\nplot_partial_dependence(\n gbdt,\n X,\n features=[0, 1],\n feature_names=(\n \"First feature\\nPositive constraint\",\n \"Second feature\\nNegtive constraint\",\n ),\n line_kw={\"linewidth\": 4, \"label\": \"constrained\", \"color\": \"tab:orange\"},\n ax=disp.axes_,\n)\n\nfor f_idx in (0, 1):\n disp.axes_[0, f_idx].plot(\n X[:, f_idx], y, \"o\", alpha=0.3, zorder=-1, color=\"tab:green\"\n )\n disp.axes_[0, f_idx].set_ylim(-6, 6)\n\nplt.legend()\nfig.suptitle(\"Monotonic constraints illustration\")\n\nplt.show()"
29+
"from sklearn.ensemble import HistGradientBoostingRegressor\nfrom sklearn.inspection import plot_partial_dependence\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\nprint(__doc__)\n\nrng = np.random.RandomState(0)\n\nn_samples = 5000\nf_0 = rng.rand(n_samples) # positive correlation with y\nf_1 = rng.rand(n_samples) # negative correlation with y\nX = np.c_[f_0, f_1]\nnoise = rng.normal(loc=0.0, scale=0.01, size=n_samples)\ny = (5 * f_0 + np.sin(10 * np.pi * f_0) -\n 5 * f_1 - np.cos(10 * np.pi * f_1) +\n noise)\n\nfig, ax = plt.subplots()\n\n\n# Without any constraint\ngbdt = HistGradientBoostingRegressor()\ngbdt.fit(X, y)\ndisp = plot_partial_dependence(\n gbdt,\n X,\n features=[0, 1],\n line_kw={\"linewidth\": 4, \"label\": \"unconstrained\", \"color\": \"tab:blue\"},\n ax=ax,\n)\n\n# With positive and negative constraints\ngbdt = HistGradientBoostingRegressor(monotonic_cst=[1, -1])\ngbdt.fit(X, y)\n\nplot_partial_dependence(\n gbdt,\n X,\n features=[0, 1],\n feature_names=(\n \"First feature\\nPositive constraint\",\n \"Second feature\\nNegtive constraint\",\n ),\n line_kw={\"linewidth\": 4, \"label\": \"constrained\", \"color\": \"tab:orange\"},\n ax=disp.axes_,\n)\n\nfor f_idx in (0, 1):\n disp.axes_[0, f_idx].plot(\n X[:, f_idx], y, \"o\", alpha=0.3, zorder=-1, color=\"tab:green\"\n )\n disp.axes_[0, f_idx].set_ylim(-6, 6)\n\nplt.legend()\nfig.suptitle(\"Monotonic constraints illustration\")\n\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/21b82d82985712b5de6347f382c77c86/plot_partial_dependence.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
},
9999
"outputs": [],
100100
"source": [
101-
"from sklearn.experimental import enable_hist_gradient_boosting # noqa\nfrom sklearn.ensemble import HistGradientBoostingRegressor\n\nprint(\"Training HistGradientBoostingRegressor...\")\ntic = time()\nest = HistGradientBoostingRegressor()\nest.fit(X_train, y_train)\nprint(f\"done in {time() - tic:.3f}s\")\nprint(f\"Test R2 score: {est.score(X_test, y_test):.2f}\")"
101+
"from sklearn.ensemble import HistGradientBoostingRegressor\n\nprint(\"Training HistGradientBoostingRegressor...\")\ntic = time()\nest = HistGradientBoostingRegressor()\nest.fit(X_train, y_train)\nprint(f\"done in {time() - tic:.3f}s\")\nprint(f\"Test R2 score: {est.score(X_test, y_test):.2f}\")"
102102
]
103103
},
104104
{

dev/_downloads/2e4791a177381a6102b21e44083615c8/plot_poisson_regression_non_normal_loss.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
},
189189
"outputs": [],
190190
"source": [
191-
"from sklearn.experimental import enable_hist_gradient_boosting # noqa\nfrom sklearn.ensemble import HistGradientBoostingRegressor\nfrom sklearn.preprocessing import OrdinalEncoder\n\n\ntree_preprocessor = ColumnTransformer(\n [\n (\"categorical\", OrdinalEncoder(),\n [\"VehBrand\", \"VehPower\", \"VehGas\", \"Region\", \"Area\"]),\n (\"numeric\", \"passthrough\",\n [\"VehAge\", \"DrivAge\", \"BonusMalus\", \"Density\"]),\n ],\n remainder=\"drop\",\n)\npoisson_gbrt = Pipeline([\n (\"preprocessor\", tree_preprocessor),\n (\"regressor\", HistGradientBoostingRegressor(loss=\"poisson\",\n max_leaf_nodes=128)),\n])\npoisson_gbrt.fit(df_train, df_train[\"Frequency\"],\n regressor__sample_weight=df_train[\"Exposure\"])\n\nprint(\"Poisson Gradient Boosted Trees evaluation:\")\nscore_estimator(poisson_gbrt, df_test)"
191+
"from sklearn.ensemble import HistGradientBoostingRegressor\nfrom sklearn.preprocessing import OrdinalEncoder\n\n\ntree_preprocessor = ColumnTransformer(\n [\n (\"categorical\", OrdinalEncoder(),\n [\"VehBrand\", \"VehPower\", \"VehGas\", \"Region\", \"Area\"]),\n (\"numeric\", \"passthrough\",\n [\"VehAge\", \"DrivAge\", \"BonusMalus\", \"Density\"]),\n ],\n remainder=\"drop\",\n)\npoisson_gbrt = Pipeline([\n (\"preprocessor\", tree_preprocessor),\n (\"regressor\", HistGradientBoostingRegressor(loss=\"poisson\",\n max_leaf_nodes=128)),\n])\npoisson_gbrt.fit(df_train, df_train[\"Frequency\"],\n regressor__sample_weight=df_train[\"Exposure\"])\n\nprint(\"Poisson Gradient Boosted Trees evaluation:\")\nscore_estimator(poisson_gbrt, df_test)"
192192
]
193193
},
194194
{

dev/_downloads/3c9b7bcd0b16f172ac12ffad61f3b5f0/plot_stack_predictors.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
},
150150
"outputs": [],
151151
"source": [
152-
"from sklearn.experimental import enable_hist_gradient_boosting # noqa\nfrom sklearn.ensemble import HistGradientBoostingRegressor\n\ngbdt_pipeline = make_pipeline(\n tree_preprocessor, HistGradientBoostingRegressor(random_state=0))\ngbdt_pipeline"
152+
"from sklearn.ensemble import HistGradientBoostingRegressor\n\ngbdt_pipeline = make_pipeline(\n tree_preprocessor, HistGradientBoostingRegressor(random_state=0))\ngbdt_pipeline"
153153
]
154154
},
155155
{

dev/_downloads/4f07b03421908788913e044918d8ed1e/plot_release_highlights_0_23_0.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import numpy as np
3737
from sklearn.model_selection import train_test_split
3838
from sklearn.linear_model import PoissonRegressor
39-
from sklearn.experimental import enable_hist_gradient_boosting # noqa
4039
from sklearn.ensemble import HistGradientBoostingRegressor
4140

4241
n_samples, n_features = 1000, 20
@@ -124,7 +123,6 @@
124123
from matplotlib import pyplot as plt
125124
from sklearn.model_selection import train_test_split
126125
from sklearn.inspection import plot_partial_dependence
127-
from sklearn.experimental import enable_hist_gradient_boosting # noqa
128126
from sklearn.ensemble import HistGradientBoostingRegressor
129127

130128
n_samples = 500

dev/_downloads/50040ae12dd16e7d2e79135d7793c17e/plot_release_highlights_0_22_0.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@
131131
# support for missing values (NaNs). This means that there is no need for
132132
# imputing data when training or predicting.
133133

134-
from sklearn.experimental import enable_hist_gradient_boosting # noqa
135134
from sklearn.ensemble import HistGradientBoostingClassifier
136135

137136
X = np.array([0, 1, 2, np.nan]).reshape(-1, 1)
Binary file not shown.

dev/_downloads/923fcad5e07de1ce7dc8dcbd7327c178/plot_release_highlights_0_23_0.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"outputs": [],
3535
"source": [
36-
"import numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import PoissonRegressor\nfrom sklearn.experimental import enable_hist_gradient_boosting # noqa\nfrom sklearn.ensemble import HistGradientBoostingRegressor\n\nn_samples, n_features = 1000, 20\nrng = np.random.RandomState(0)\nX = rng.randn(n_samples, n_features)\n# positive integer target correlated with X[:, 5] with many zeros:\ny = rng.poisson(lam=np.exp(X[:, 5]) / 2)\nX_train, X_test, y_train, y_test = train_test_split(X, y, random_state=rng)\nglm = PoissonRegressor()\ngbdt = HistGradientBoostingRegressor(loss='poisson', learning_rate=.01)\nglm.fit(X_train, y_train)\ngbdt.fit(X_train, y_train)\nprint(glm.score(X_test, y_test))\nprint(gbdt.score(X_test, y_test))"
36+
"import numpy as np\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import PoissonRegressor\nfrom sklearn.ensemble import HistGradientBoostingRegressor\n\nn_samples, n_features = 1000, 20\nrng = np.random.RandomState(0)\nX = rng.randn(n_samples, n_features)\n# positive integer target correlated with X[:, 5] with many zeros:\ny = rng.poisson(lam=np.exp(X[:, 5]) / 2)\nX_train, X_test, y_train, y_test = train_test_split(X, y, random_state=rng)\nglm = PoissonRegressor()\ngbdt = HistGradientBoostingRegressor(loss='poisson', learning_rate=.01)\nglm.fit(X_train, y_train)\ngbdt.fit(X_train, y_train)\nprint(glm.score(X_test, y_test))\nprint(gbdt.score(X_test, y_test))"
3737
]
3838
},
3939
{
@@ -87,7 +87,7 @@
8787
},
8888
"outputs": [],
8989
"source": [
90-
"import numpy as np\nfrom matplotlib import pyplot as plt\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.inspection import plot_partial_dependence\nfrom sklearn.experimental import enable_hist_gradient_boosting # noqa\nfrom sklearn.ensemble import HistGradientBoostingRegressor\n\nn_samples = 500\nrng = np.random.RandomState(0)\nX = rng.randn(n_samples, 2)\nnoise = rng.normal(loc=0.0, scale=0.01, size=n_samples)\ny = (5 * X[:, 0] + np.sin(10 * np.pi * X[:, 0]) - noise)\n\ngbdt_no_cst = HistGradientBoostingRegressor().fit(X, y)\ngbdt_cst = HistGradientBoostingRegressor(monotonic_cst=[1, 0]).fit(X, y)\n\ndisp = plot_partial_dependence(\n gbdt_no_cst, X, features=[0], feature_names=['feature 0'],\n line_kw={'linewidth': 4, 'label': 'unconstrained', \"color\": \"tab:blue\"})\nplot_partial_dependence(gbdt_cst, X, features=[0],\n line_kw={'linewidth': 4, 'label': 'constrained', \"color\": \"tab:orange\"},\n ax=disp.axes_)\ndisp.axes_[0, 0].plot(\n X[:, 0], y, 'o', alpha=.5, zorder=-1, label='samples', color=\"tab:green\"\n)\ndisp.axes_[0, 0].set_ylim(-3, 3); disp.axes_[0, 0].set_xlim(-1, 1)\nplt.legend()\nplt.show()"
90+
"import numpy as np\nfrom matplotlib import pyplot as plt\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.inspection import plot_partial_dependence\nfrom sklearn.ensemble import HistGradientBoostingRegressor\n\nn_samples = 500\nrng = np.random.RandomState(0)\nX = rng.randn(n_samples, 2)\nnoise = rng.normal(loc=0.0, scale=0.01, size=n_samples)\ny = (5 * X[:, 0] + np.sin(10 * np.pi * X[:, 0]) - noise)\n\ngbdt_no_cst = HistGradientBoostingRegressor().fit(X, y)\ngbdt_cst = HistGradientBoostingRegressor(monotonic_cst=[1, 0]).fit(X, y)\n\ndisp = plot_partial_dependence(\n gbdt_no_cst, X, features=[0], feature_names=['feature 0'],\n line_kw={'linewidth': 4, 'label': 'unconstrained', \"color\": \"tab:blue\"})\nplot_partial_dependence(gbdt_cst, X, features=[0],\n line_kw={'linewidth': 4, 'label': 'constrained', \"color\": \"tab:orange\"},\n ax=disp.axes_)\ndisp.axes_[0, 0].plot(\n X[:, 0], y, 'o', alpha=.5, zorder=-1, label='samples', color=\"tab:green\"\n)\ndisp.axes_[0, 0].set_ylim(-3, 3); disp.axes_[0, 0].set_xlim(-1, 1)\nplt.legend()\nplt.show()"
9191
]
9292
},
9393
{

dev/_downloads/9e22207e9bd6485b95f32783b59d9a80/plot_monotonic_constraints.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
This example was inspired by the `XGBoost documentation
1919
<https://xgboost.readthedocs.io/en/latest/tutorials/monotonic.html>`_.
2020
"""
21-
from sklearn.experimental import enable_hist_gradient_boosting # noqa
2221
from sklearn.ensemble import HistGradientBoostingRegressor
2322
from sklearn.inspection import plot_partial_dependence
2423
import numpy as np

0 commit comments

Comments
 (0)