From d67673a29041b8150bd153c8f204070667311f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Tue, 14 Nov 2023 12:57:41 +1300 Subject: [PATCH] Add dual=True to LinearSVC and parser='auto' to fetch_openml --- 07_ensemble_learning_and_random_forests.ipynb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/07_ensemble_learning_and_random_forests.ipynb b/07_ensemble_learning_and_random_forests.ipynb index db3f001..6222ceb 100644 --- a/07_ensemble_learning_and_random_forests.ipynb +++ b/07_ensemble_learning_and_random_forests.ipynb @@ -636,7 +636,8 @@ "\n", "from sklearn.datasets import fetch_openml\n", "\n", - "X_mnist, y_mnist = fetch_openml('mnist_784', return_X_y=True, as_frame=False)\n", + "X_mnist, y_mnist = fetch_openml('mnist_784', return_X_y=True, as_frame=False,\n", + " parser='auto')\n", "\n", "rnd_clf = RandomForestClassifier(n_estimators=100, random_state=42)\n", "rnd_clf.fit(X_mnist, y_mnist)\n", @@ -1305,6 +1306,13 @@ "from sklearn.neural_network import MLPClassifier" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note: The `LinearSVC` has a `dual` hyperparameter whose default value will change from `True` to `\"auto\"` in Scikit-Learn 1.5. To ensure this notebook continues to produce the same outputs, I'm setting it explicitly to `True`. Please see the [documentation](https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html) for more details." + ] + }, { "cell_type": "code", "execution_count": 42, @@ -1313,7 +1321,7 @@ "source": [ "random_forest_clf = RandomForestClassifier(n_estimators=100, random_state=42)\n", "extra_trees_clf = ExtraTreesClassifier(n_estimators=100, random_state=42)\n", - "svm_clf = LinearSVC(max_iter=100, tol=20, random_state=42)\n", + "svm_clf = LinearSVC(max_iter=100, tol=20, dual=True, random_state=42)\n", "mlp_clf = MLPClassifier(random_state=42)" ] }, @@ -2045,7 +2053,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -2059,7 +2067,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.13" }, "nav_menu": { "height": "252px",