diff --git a/.gitignore b/.gitignore index c3bb071..1737334 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,6 @@ target/ # IPython .ipynb_checkpoints notebooks/.ipynb_checkpoints - +/.idea # Emacs *~ \ No newline at end of file diff --git a/README.md b/README.md index 9359885..60a87f5 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,20 @@ Once this is installed, the following command will install all required packages Original install (2015) $ conda install numpy scipy matplotlib scikit-learn ipython-notebook seaborn -Or for current versions of Anaconda (Mar 2018) +For older version Anaconda (Mar 2018) $ conda create -n skl_tut python=3.4.5 ipywidgets=5.2.2 numpy scipy matplotlib scikit-learn ipython-notebook seaborn pillow +``` -$ activate skl_tut +**For current (2023) version of the project:** +``` +$ conda create -n skl_tut python=3.10.8 --file requirements.txt +``` +``` +$ activate skl_tut +``` +``` $ jupyter notebook --notebook-dir='' ``` diff --git a/notebooks/01-Preliminaries.ipynb b/notebooks/01-Preliminaries.ipynb index 4720b07..a871920 100644 --- a/notebooks/01-Preliminaries.ipynb +++ b/notebooks/01-Preliminaries.ipynb @@ -115,9 +115,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "IPython: 8.10.0\n", + "numpy: 1.23.5\n", + "scipy: 1.10.0\n", + "matplotlib: 3.6.2\n", + "scikit-learn: 1.2.1\n", + "seaborn: 0.12.2\n" + ] + } + ], "source": [ "from __future__ import print_function\n", "\n", @@ -134,7 +147,10 @@ "print('matplotlib:', matplotlib.__version__)\n", "\n", "import sklearn\n", - "print('scikit-learn:', sklearn.__version__)" + "print('scikit-learn:', sklearn.__version__)\n", + "\n", + "import seaborn\n", + "print('seaborn:', seaborn.__version__)" ] }, { @@ -156,7 +172,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -170,9 +186,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/02.1-Machine-Learning-Intro.ipynb b/notebooks/02.1-Machine-Learning-Intro.ipynb index 7a60ca9..0207ff9 100644 --- a/notebooks/02.1-Machine-Learning-Intro.ipynb +++ b/notebooks/02.1-Machine-Learning-Intro.ipynb @@ -71,10 +71,8 @@ "metadata": {}, "outputs": [], "source": [ - "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", - "\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -194,7 +192,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.core.display import Image, display\n", + "from IPython.display import Image, display\n", "display(Image(filename='images/iris_setosa.jpg'))\n", "print(\"Iris Setosa\\n\")\n", "\n", @@ -422,7 +420,7 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -436,9 +434,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/02.2-Basic-Principles.ipynb b/notebooks/02.2-Basic-Principles.ipynb index 00b4298..7690eca 100644 --- a/notebooks/02.2-Basic-Principles.ipynb +++ b/notebooks/02.2-Basic-Principles.ipynb @@ -30,10 +30,9 @@ "metadata": {}, "outputs": [], "source": [ - "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -51,7 +50,8 @@ "metadata": {}, "outputs": [], "source": [ - "from sklearn.linear_model import LinearRegression" + "from sklearn.linear_model import LinearRegression\n", + "from sklearn.preprocessing import normalize" ] }, { @@ -67,8 +67,7 @@ "metadata": {}, "outputs": [], "source": [ - "model = LinearRegression(normalize=True)\n", - "print(model.normalize)" + "model = LinearRegression() # normalize=True is no longer an argument, not using it does not seem to affect the result here" ] }, { @@ -471,7 +470,7 @@ "outputs": [], "source": [ "from sklearn.cluster import KMeans\n", - "k_means = KMeans(n_clusters=3, random_state=0) # Fixing the RNG in kmeans\n", + "k_means = KMeans(n_clusters=3, random_state=0, n_init='auto') # Fixing the RNG in kmeans\n", "k_means.fit(X)\n", "y_pred = k_means.predict(X)\n", "\n", @@ -740,7 +739,7 @@ "metadata": {}, "outputs": [], "source": [ - "iso = Isomap(n_components=2)\n", + "iso = Isomap(n_components=2, n_neighbors=7)\n", "data_projected = iso.fit_transform(digits.data)" ] }, @@ -807,8 +806,16 @@ "outputs": [], "source": [ "from sklearn.linear_model import LogisticRegression\n", - "clf = LogisticRegression(penalty='l2')\n", - "clf.fit(Xtrain, ytrain)\n", + "from sklearn import preprocessing\n", + "\n", + "scaler = preprocessing.StandardScaler().fit(Xtrain) # Scale data to avoid 'ConvergenceWarning: lbfgs failed to converge (status=1)'\n", + "X_scaled = scaler.transform(Xtrain)\n", + "\n", + "scaler_test = preprocessing.StandardScaler().fit(Xtest)\n", + "Xtest = scaler.transform(Xtest)\n", + "\n", + "clf = LogisticRegression(penalty='l2', max_iter=150) # Increase max_iter from 100 to 150 to avoid 'ConvergenceWarning: lbfgs failed to converge (status=1)'\n", + "clf.fit(X_scaled, ytrain)\n", "ypred = clf.predict(Xtest)" ] }, @@ -897,7 +904,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -911,9 +918,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/03.1-Classification-SVMs.ipynb b/notebooks/03.1-Classification-SVMs.ipynb index 3027885..79d5e18 100644 --- a/notebooks/03.1-Classification-SVMs.ipynb +++ b/notebooks/03.1-Classification-SVMs.ipynb @@ -28,12 +28,11 @@ "metadata": {}, "outputs": [], "source": [ - "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy import stats\n", "\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -58,7 +57,7 @@ "metadata": {}, "outputs": [], "source": [ - "from sklearn.datasets.samples_generator import make_blobs\n", + "from sklearn.datasets import make_blobs\n", "X, y = make_blobs(n_samples=50, centers=2,\n", " random_state=0, cluster_std=0.60)\n", "plt.scatter(X[:, 0], X[:, 1], c=y, s=50, cmap='spring');" @@ -240,7 +239,7 @@ " plt.scatter(clf.support_vectors_[:, 0], clf.support_vectors_[:, 1],\n", " s=200, facecolors='none')\n", " \n", - "interact(plot_svm, N=[10, 200], kernel='linear');" + "interact(plot_svm, N=(10, 200), kernel='linear');" ] }, { @@ -266,7 +265,7 @@ "metadata": {}, "outputs": [], "source": [ - "from sklearn.datasets.samples_generator import make_circles\n", + "from sklearn.datasets import make_circles\n", "X, y = make_circles(100, factor=.1, noise=.1)\n", "\n", "clf = SVC(kernel='linear').fit(X, y)\n", @@ -355,7 +354,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -369,9 +368,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/03.2-Regression-Forests.ipynb b/notebooks/03.2-Regression-Forests.ipynb index 9285639..d401e37 100644 --- a/notebooks/03.2-Regression-Forests.ipynb +++ b/notebooks/03.2-Regression-Forests.ipynb @@ -28,12 +28,11 @@ "metadata": {}, "outputs": [], "source": [ - "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy import stats\n", "\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -410,7 +409,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -424,9 +423,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/04.1-Dimensionality-PCA.ipynb b/notebooks/04.1-Dimensionality-PCA.ipynb index 32d8b2f..770e3fb 100644 --- a/notebooks/04.1-Dimensionality-PCA.ipynb +++ b/notebooks/04.1-Dimensionality-PCA.ipynb @@ -26,12 +26,11 @@ "source": [ "from __future__ import print_function, division\n", "\n", - "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy import stats\n", "\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -355,7 +354,7 @@ " size=18)\n", " plt.clim(0, 16)\n", " \n", - "interact(plot_digits, n_components=[1, 64], nside=[1, 8]);" + "interact(plot_digits, n_components=(1, 64), nside=[1, 8]);" ] }, { @@ -388,7 +387,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -402,9 +401,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/04.2-Clustering-KMeans.ipynb b/notebooks/04.2-Clustering-KMeans.ipynb index 70d63d5..c97b53b 100644 --- a/notebooks/04.2-Clustering-KMeans.ipynb +++ b/notebooks/04.2-Clustering-KMeans.ipynb @@ -29,12 +29,11 @@ "metadata": {}, "outputs": [], "source": [ - "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy import stats\n", "\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -61,7 +60,7 @@ "metadata": {}, "outputs": [], "source": [ - "from sklearn.datasets.samples_generator import make_blobs\n", + "from sklearn.datasets import make_blobs\n", "X, y = make_blobs(n_samples=300, centers=4,\n", " random_state=0, cluster_std=0.60)\n", "plt.scatter(X[:, 0], X[:, 1], s=50);" @@ -81,7 +80,7 @@ "outputs": [], "source": [ "from sklearn.cluster import KMeans\n", - "est = KMeans(4) # 4 clusters\n", + "est = KMeans(4, n_init='auto') # 4 clusters\n", "est.fit(X)\n", "y_kmeans = est.predict(X)\n", "plt.scatter(X[:, 0], X[:, 1], c=y_kmeans, s=50, cmap='rainbow');" @@ -164,7 +163,7 @@ "metadata": {}, "outputs": [], "source": [ - "est = KMeans(n_clusters=10)\n", + "est = KMeans(n_clusters=10, n_init='auto')\n", "clusters = est.fit_predict(digits.data)\n", "est.cluster_centers_.shape" ] @@ -208,7 +207,7 @@ "labels = np.zeros_like(clusters)\n", "for i in range(10):\n", " mask = (clusters == i)\n", - " labels[mask] = mode(digits.target[mask])[0]" + " labels[mask] = mode(digits.target[mask], keepdims=True)[0]" ] }, { @@ -373,7 +372,7 @@ "\n", "X = (china / 255.0).reshape(-1, 3)\n", " \n", - "model = MiniBatchKMeans(n_colors)\n", + "model = MiniBatchKMeans(n_colors, n_init='auto')\n", "labels = model.fit_predict(X)\n", "colors = model.cluster_centers_\n", "new_image = colors[labels].reshape(china.shape)\n", @@ -400,7 +399,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -414,9 +413,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/04.3-Density-GMM.ipynb b/notebooks/04.3-Density-GMM.ipynb index bdf354b..b91444e 100644 --- a/notebooks/04.3-Density-GMM.ipynb +++ b/notebooks/04.3-Density-GMM.ipynb @@ -29,12 +29,11 @@ "metadata": {}, "outputs": [], "source": [ - "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy import stats\n", "\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -60,7 +59,7 @@ "x = np.concatenate([np.random.normal(0, 2, 2000),\n", " np.random.normal(5, 5, 2000),\n", " np.random.normal(3, 0.5, 600)])\n", - "plt.hist(x, 80, normed=True)\n", + "plt.hist(x, 80, density=True)\n", "plt.xlim(-10, 20);" ] }, @@ -143,7 +142,7 @@ "metadata": {}, "outputs": [], "source": [ - "plt.hist(x, 80, normed=True, alpha=0.3)\n", + "plt.hist(x, 80, density=True, alpha=0.3)\n", "plt.plot(xpdf, density, '-r')\n", "\n", "for i in range(clf.n_components):\n", @@ -342,7 +341,7 @@ "outputs": [], "source": [ "from sklearn.neighbors import KernelDensity\n", - "kde = KernelDensity(0.15).fit(x[:, None])\n", + "kde = KernelDensity(bandwidth=0.15).fit(x[:, None])\n", "density_kde = np.exp(kde.score_samples(xpdf[:, None]))\n", "\n", "plt.hist(x, 80, density=True, alpha=0.5)\n", @@ -369,7 +368,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -383,9 +382,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/05-Validation.ipynb b/notebooks/05-Validation.ipynb index 5e7c95b..57adb70 100644 --- a/notebooks/05-Validation.ipynb +++ b/notebooks/05-Validation.ipynb @@ -29,11 +29,10 @@ "source": [ "from __future__ import print_function, division\n", "\n", - "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", - "plt.style.use('seaborn')" + "plt.style.use(\"seaborn-v0_8-darkgrid\")" ] }, { @@ -156,7 +155,7 @@ "knn = KNeighborsClassifier(n_neighbors=1)\n", "knn.fit(X_train, y_train)\n", "y_pred = knn.predict(X_test)\n", - "print(\"{0} / {1} correct\".format(np.sum(y_test == y_pred), len(y_test)))" + "print(\"{0} / {1} correct\".format(np.sum(y_test == y_pred), len(y_test))) # Eventually update to use f-strings" ] }, { @@ -505,7 +504,7 @@ "metadata": {}, "outputs": [], "source": [ - "from IPython.html.widgets import interact\n", + "from ipywidgets import interact\n", "\n", "def plot_fit(degree=1, Npts=50):\n", " X, y = make_data(Npts, error=1)\n", @@ -520,7 +519,7 @@ " plt.ylim(-4, 14)\n", " plt.title(\"mean squared error: {0:.2f}\".format(mean_squared_error(model.predict(X), y)))\n", " \n", - "interact(plot_fit, degree=[1, 30], Npts=[2, 100]);" + "interact(plot_fit, degree=(1, 30), Npts=(2, 100));" ] }, { @@ -557,8 +556,8 @@ " return np.sqrt(np.mean((y - y_pred) ** 2))\n", "\n", "degree = np.arange(0, 18)\n", - "val_train, val_test = validation_curve(PolynomialRegression(), X, y,\n", - " 'polynomialfeatures__degree', degree, cv=7,\n", + "val_train, val_test = validation_curve(estimator=PolynomialRegression(), X=X, y=y,\n", + " param_name='polynomialfeatures__degree', param_range=degree, cv=7,\n", " scoring=rms_error)" ] }, @@ -634,8 +633,8 @@ "\n", "def plot_learning_curve(degree=3):\n", " train_sizes = np.linspace(0.05, 1, 120)\n", - " N_train, val_train, val_test = learning_curve(PolynomialRegression(degree),\n", - " X, y, train_sizes, cv=5,\n", + " N_train, val_train, val_test = learning_curve(estimator=PolynomialRegression(degree),\n", + " X=X, y=y, train_sizes=train_sizes, cv=5,\n", " scoring=rms_error)\n", " plot_with_err(N_train, val_train, label='training scores')\n", " plot_with_err(N_train, val_test, label='validation scores')\n", @@ -739,7 +738,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -753,9 +752,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.10.8" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/notebooks/Index.ipynb b/notebooks/Index.ipynb index 831a40e..1dea58d 100644 --- a/notebooks/Index.ipynb +++ b/notebooks/Index.ipynb @@ -1,62 +1,74 @@ { - "metadata": { - "name": "", - "signature": "sha256:60efb1a2f4e1815d3e1a54160adf3184ab956d9a4487c226bde9b22aa2728f94" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ + "cells": [ + { + "cell_type": "markdown", + "id": "53788279", + "metadata": {}, + "source": [ + "# Scikit-Learn Tutorial\n", + "\n", + "*Jake VanderPlas*\n", + "\n", + "This is the main index for the materials of my Scikit-Learn tutorial.\n", + "Please refer to the [github repository](http://github.com/jakevdp/sklearn_tutorial) for this tutorial for any updates." + ] + }, { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Scikit-Learn Tutorial\n", - "\n", - "*Jake VanderPlas*\n", - "\n", - "This is the main index for the materials of my Scikit-Learn tutorial.\n", - "Please refer to the [github repository](http://github.com/jakevdp/sklearn_tutorial) for this tutorial for any updates." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tutorial Notebooks\n", - "\n", - "The following links are to notebooks containing the tutorial materials.\n", - "Note that many of these require files that are in the directory structure of the [github repository](http://github.com/jakevdp/sklearn_tutorial) in which they are contained.\n", - "There is not time during the tutorial to cover all of this material, but I left it in in case attendees would like to go deeper on their own.\n", - "\n", - "### 1. Preliminaries\n", - "\n", - " + [01-Preliminaries.ipynb](01-Preliminaries.ipynb)\n", - " \n", - "### 2. Introduction to Machine Learning with Scikit-Learn\n", - "\n", - " + [02.1-Machine-Learning-Intro.ipynb](02.1-Machine-Learning-Intro.ipynb)\n", - " + [02.2-Basic-Principles.ipynb](02.2-Basic-Principles.ipynb)\n", - " \n", - "### 3. Supervised Learning In-Depth\n", - "\n", - " + [03.1-Classification-SVMs.ipynb](03.1-Classification-SVMs.ipynb)\n", - " + [03.2-Regression-Forests.ipynb](03.2-Regression-Forests.ipynb)\n", - "\n", - "### 4. Unsupervised Learning In-Depth\n", - "\n", - " + [04.1-Dimensionality-PCA.ipynb](04.1-Dimensionality-PCA.ipynb)\n", - " + [04.2-Clustering-KMeans.ipynb](04.2-Clustering-KMeans.ipynb)\n", - " + [04.3-Density-GMM.ipynb](04.3-Density-GMM.ipynb)\n", - " \n", - "### 5. Model Validation In-Depth\n", - "\n", - " + [05-Validation.ipynb](05-Validation.ipynb)" - ] - } - ], - "metadata": {} + "cell_type": "markdown", + "id": "322148f6", + "metadata": {}, + "source": [ + "## Tutorial Notebooks\n", + "\n", + "The following links are to notebooks containing the tutorial materials.\n", + "Note that many of these require files that are in the directory structure of the [github repository](http://github.com/jakevdp/sklearn_tutorial) in which they are contained.\n", + "There is not time during the tutorial to cover all of this material, but I left it in in case attendees would like to go deeper on their own.\n", + "\n", + "### 1. Preliminaries\n", + "\n", + " + [01-Preliminaries.ipynb](01-Preliminaries.ipynb)\n", + " \n", + "### 2. Introduction to Machine Learning with Scikit-Learn\n", + "\n", + " + [02.1-Machine-Learning-Intro.ipynb](02.1-Machine-Learning-Intro.ipynb)\n", + " + [02.2-Basic-Principles.ipynb](02.2-Basic-Principles.ipynb)\n", + " \n", + "### 3. Supervised Learning In-Depth\n", + "\n", + " + [03.1-Classification-SVMs.ipynb](03.1-Classification-SVMs.ipynb)\n", + " + [03.2-Regression-Forests.ipynb](03.2-Regression-Forests.ipynb)\n", + "\n", + "### 4. Unsupervised Learning In-Depth\n", + "\n", + " + [04.1-Dimensionality-PCA.ipynb](04.1-Dimensionality-PCA.ipynb)\n", + " + [04.2-Clustering-KMeans.ipynb](04.2-Clustering-KMeans.ipynb)\n", + " + [04.3-Density-GMM.ipynb](04.3-Density-GMM.ipynb)\n", + " \n", + "### 5. Model Validation In-Depth\n", + "\n", + " + [05-Validation.ipynb](05-Validation.ipynb)" + ] } - ] -} \ No newline at end of file + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/URL.ipynb b/notebooks/URL.ipynb index 23d6a3f..323b02f 100644 --- a/notebooks/URL.ipynb +++ b/notebooks/URL.ipynb @@ -1,7 +1,28 @@ { + "cells": [ + { + "cell_type": "markdown", + "id": "9beb9520", + "metadata": {}, + "source": [ + "# Scikit-Learn Tutorial\n", + "\n", + "---\n", + "\n", + "


\n", + "\n", + "# Download all materials here:\n", + "# http://github.com/jakevdp/sklearn_tutorial\n", + "\n", + "





\n", + "\n", + "---" + ] + } + ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -15,36 +36,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.3.5" - }, - "name": "", - "signature": "sha256:5941485b19c03919025faae3887fd7ef842661eae6780930de41597909742c69" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Scikit-Learn Tutorial\n", - "\n", - "---\n", - "\n", - "


\n", - "\n", - "# Download all materials here:\n", - "# http://github.com/jakevdp/sklearn_tutorial\n", - "\n", - "





\n", - "\n", - "---" - ] - } - ], - "metadata": {} + "version": "3.10.8" } - ] -} \ No newline at end of file + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/fig_code/figures.py b/notebooks/fig_code/figures.py index 311ba50..6650194 100644 --- a/notebooks/fig_code/figures.py +++ b/notebooks/fig_code/figures.py @@ -119,7 +119,7 @@ def interactive_tree(depth=1): def plot_kmeans_interactive(min_clusters=1, max_clusters=6): from ipywidgets import interact from sklearn.metrics.pairwise import euclidean_distances - from sklearn.datasets.samples_generator import make_blobs + from sklearn.datasets import make_blobs with warnings.catch_warnings(): warnings.filterwarnings('ignore') diff --git a/notebooks/fig_code/sgd_separator.py b/notebooks/fig_code/sgd_separator.py index fe9c805..b3bbd38 100644 --- a/notebooks/fig_code/sgd_separator.py +++ b/notebooks/fig_code/sgd_separator.py @@ -1,7 +1,7 @@ import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import SGDClassifier -from sklearn.datasets.samples_generator import make_blobs +from sklearn.datasets import make_blobs def plot_sgd_separator(): # we create 50 separable points diff --git a/requirements.txt b/requirements.txt index 30f39a8..afb0a85 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -numpy -scipy -matplotlib -scikit-learn -ipython -seaborn \ No newline at end of file +numpy==1.23.5 +matplotlib==3.6.2 +scikit-learn==1.2.1 +scipy==1.10.0 +ipython==8.10.0 +seaborn==0.12.2 \ No newline at end of file