From f8f2b9e4bb0ebcbcbcf623d415aa64e9bb75f925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Wed, 10 Jul 2019 17:08:12 +0200 Subject: [PATCH] Add (USD) after GDP per capita --- 01_the_machine_learning_landscape.ipynb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/01_the_machine_learning_landscape.ipynb b/01_the_machine_learning_landscape.ipynb index 9c51dae..15df3da 100644 --- a/01_the_machine_learning_landscape.ipynb +++ b/01_the_machine_learning_landscape.ipynb @@ -353,6 +353,7 @@ " plt.annotate(country, xy=(pos_data_x, pos_data_y), xytext=pos_text,\n", " arrowprops=dict(facecolor='black', width=0.5, shrink=0.1, headwidth=5))\n", " plt.plot(pos_data_x, pos_data_y, \"ro\")\n", + "plt.xlabel(\"GDP per capita (USD)\")\n", "save_fig('money_happy_scatterplot')\n", "plt.show()" ] @@ -384,6 +385,7 @@ "import numpy as np\n", "\n", "sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\n", + "plt.xlabel(\"GDP per capita (USD)\")\n", "plt.axis([0, 60000, 0, 10])\n", "X=np.linspace(0, 60000, 1000)\n", "plt.plot(X, 2*X/100000, \"r\")\n", @@ -421,6 +423,7 @@ "outputs": [], "source": [ "sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\n", + "plt.xlabel(\"GDP per capita (USD)\")\n", "plt.axis([0, 60000, 0, 10])\n", "X=np.linspace(0, 60000, 1000)\n", "plt.plot(X, t0 + t1*X, \"b\")\n", @@ -449,6 +452,7 @@ "outputs": [], "source": [ "sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3), s=1)\n", + "plt.xlabel(\"GDP per capita (USD)\")\n", "X=np.linspace(0, 60000, 1000)\n", "plt.plot(X, t0 + t1*X, \"b\")\n", "plt.axis([0, 60000, 0, 10])\n", @@ -598,6 +602,7 @@ "t0full, t1full = lin_reg_full.intercept_[0], lin_reg_full.coef_[0][0]\n", "X = np.linspace(0, 110000, 1000)\n", "plt.plot(X, t0full + t1full * X, \"k\")\n", + "plt.xlabel(\"GDP per capita (USD)\")\n", "\n", "save_fig('representative_training_data_scatterplot')\n", "plt.show()" @@ -623,6 +628,7 @@ "pipeline_reg.fit(Xfull, yfull)\n", "curve = pipeline_reg.predict(X[:, np.newaxis])\n", "plt.plot(X, curve)\n", + "plt.xlabel(\"GDP per capita (USD)\")\n", "save_fig('overfitting_model_plot')\n", "plt.show()" ] @@ -672,6 +678,7 @@ "\n", "plt.legend(loc=\"lower right\")\n", "plt.axis([0, 110000, 0, 10])\n", + "plt.xlabel(\"GDP per capita (USD)\")\n", "save_fig('ridge_model_plot')\n", "plt.show()" ] @@ -726,6 +733,13 @@ "X_new = np.array([[22587.0]]) # Cyprus' GDP per capita\n", "print(model.predict(X_new)) # outputs [[ 5.76666667]]" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {