From 65426f3400f8013bd36ff3b84907e58b6cea231c Mon Sep 17 00:00:00 2001 From: baniasbaabe Date: Sun, 7 Apr 2024 18:43:56 +0200 Subject: [PATCH] Add scikit-lego --- book/machinelearning/modeltraining.ipynb | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/book/machinelearning/modeltraining.ipynb b/book/machinelearning/modeltraining.ipynb index d8bcee6..338b995 100644 --- a/book/machinelearning/modeltraining.ipynb +++ b/book/machinelearning/modeltraining.ipynb @@ -1889,6 +1889,56 @@ "alpha = [0.05, 0.20]\n", "y_pred, y_pis = mapie_regressor.predict(X_test, alpha=alpha)" ] + }, + { + "cell_type": "markdown", + "id": "bc7f6fab", + "metadata": {}, + "source": [ + "## Extra Components For scikit-learn with `scikit-lego`" + ] + }, + { + "cell_type": "markdown", + "id": "29e041d4", + "metadata": {}, + "source": [ + "scikit-learn is one of the most popular ML libraries.\n", + "\n", + "While it's easy to write custom components, it would be nice to have all of them in a single place.\n", + "\n", + "`scikit-lego` is such a library which contains many custom components like:\n", + "\n", + "- `DebugPipeline`, which adds debug information to pipelines\n", + "- `ImbalancedLinearRegression` to punish over-/underestimation of a model\n", + "- `add_lags` to add lag values to a DataFrame\n", + "- `ZeroInflatedRegressor` which predicts zero or applies a regression based on a classifier\n", + "\n", + "and many more!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f2c86d37", + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.preprocessing import StandardScaler\n", + "from sklearn.pipeline import Pipeline\n", + "from sklego.preprocessing import RandomAdder\n", + "from sklego.mixture import GMMClassifier\n", + "\n", + "...\n", + "\n", + "pipeline = Pipeline([\n", + " (\"scale\", StandardScaler()),\n", + " (\"random_noise\", RandomAdder()),\n", + " (\"model\", GMMClassifier())\n", + "])\n", + "\n", + "..." + ] } ], "metadata": {