From 3edb8cd51b3b77528b1f59a3186ddd5155f88fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerardo=20Marx=20Cha=CC=81vez-Campos?= Date: Mon, 3 Jul 2023 09:23:28 -0600 Subject: [PATCH] updating 1-ml-landscape --- 1-ml-landscape/main.ipynb | 135 +++++++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 39 deletions(-) diff --git a/1-ml-landscape/main.ipynb b/1-ml-landscape/main.ipynb index 5dc472a..e3de416 100644 --- a/1-ml-landscape/main.ipynb +++ b/1-ml-landscape/main.ipynb @@ -17,11 +17,10 @@ "\n", "Objetivos Específicos:\n", "\n", - "- Aprender el arranque y manejo básico de la plataforma Jupyter y los comandos de inserción, copia, borrado y evaluación de celdas\n", - "- Identificar el procedimiento de instalación de módulos nuevos en Python usando el comando **pip3​** \n", + "- Aprender el manejo básico de la plataforma Jupyter y los comandos de inserción, copia, borrado y evaluación de celdas\n", "- Conocer el procedimiento de lectura de archivos CSV\n", "- Relacionarse con el procedimiento de acceso a datos por nombres de columnas, manipulación, edición y filtrado de datos con la estructura de Pandas\n", - "- Crear una función en Python para leer las bases de datos de la OECD y GDP, y posteriormente crear una nueva base de datos que exclusivamente incluyan \"Life Satisfaction\" y \"GDP per capita\"\n", + "- Crear una función en Python para leer las bases de datos de la OECD y GDP, y posteriormente crear un conjunto de datos que exclusivamente incluyan \"Life Satisfaction\" y \"GDP per capita\"\n", "- Entrenar un modelo basado en la regresión lineal \n", "- Comparar el modelo con los datos reales y determinar nuevos valores de instancias" ] @@ -112,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "id": "86e530da", "metadata": {}, "outputs": [ @@ -158,7 +157,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "id": "7a58ef40", "metadata": {}, "outputs": [ @@ -497,7 +496,7 @@ "[3292 rows x 17 columns]" ] }, - "execution_count": 4, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -508,7 +507,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "id": "d1c803f7", "metadata": {}, "outputs": [ @@ -550,7 +549,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "id": "426e54c9", "metadata": {}, "outputs": [ @@ -592,7 +591,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 10, "id": "20e499fb", "metadata": {}, "outputs": [ @@ -1962,7 +1961,7 @@ "[37 rows x 24 columns]" ] }, - "execution_count": 15, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -1978,6 +1977,15 @@ "metadata": {}, "source": [ "## GDP per capita\n", + "\n", + "*Gross domestic product* (GDP) per capita is an economic metric that breaks down a country's economic output per person. Economists use GDP per capita to determine how prosperous countries are based on their economic growth.\n", + "\n", + "GDP per capita is calculated by dividing the GDP of a nation by its population. Countries with the higher GDP per capita tend to be those that are industrial, developed countries.\n", + "\n", + "Thus, **GDP per capita measures the economic output of a nation per person.**\n", + "\n", + "---\n", + "\n", "The Dataset obtained from the IMF's website at: http://goo.gl/j1MSKe\n", "\n", "### Data description\n", @@ -2008,7 +2016,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 13, "id": "fc31575a", "metadata": {}, "outputs": [ @@ -2214,7 +2222,7 @@ "[190 rows x 7 columns]" ] }, - "execution_count": 17, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -2227,7 +2235,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 14, "id": "b355820d", "metadata": {}, "outputs": [ @@ -2433,7 +2441,7 @@ "[190 rows x 7 columns]" ] }, - "execution_count": 18, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -2445,7 +2453,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 15, "id": "44bce56b", "metadata": {}, "outputs": [ @@ -2666,7 +2674,7 @@ "[190 rows x 6 columns]" ] }, - "execution_count": 19, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -2698,7 +2706,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 16, "id": "37cd9901", "metadata": {}, "outputs": [], @@ -2711,7 +2719,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 17, "id": "df9ca7f1", "metadata": {}, "outputs": [ @@ -2929,7 +2937,7 @@ "United States 55805.204 7.2" ] }, - "execution_count": 23, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -3014,6 +3022,55 @@ { "cell_type": "code", "execution_count": 20, + "id": "ba85eda2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[6. ],\n", + " [5.6],\n", + " [4.9],\n", + " [5.8],\n", + " [6.1],\n", + " [5.6],\n", + " [4.8],\n", + " [5.1],\n", + " [5.7],\n", + " [6.5],\n", + " [5.8],\n", + " [6. ],\n", + " [5.9],\n", + " [7.4],\n", + " [7.3],\n", + " [6.5],\n", + " [6.9],\n", + " [7. ],\n", + " [7.4],\n", + " [7.3],\n", + " [7.3],\n", + " [6.9],\n", + " [6.8],\n", + " [7.2],\n", + " [7.5],\n", + " [7.3],\n", + " [7. ],\n", + " [7.5],\n", + " [7.2]])" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "y" + ] + }, + { + "cell_type": "code", + "execution_count": 21, "id": "75460ea4", "metadata": {}, "outputs": [ @@ -3047,29 +3104,37 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 24, + "id": "13fabb3b", + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.linear_model import LinearRegression\n", + "# Select a linear model\n", + "model = LinearRegression()" + ] + }, + { + "cell_type": "code", + "execution_count": 25, "id": "86ee41bd", "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
LinearRegression()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" + "
LinearRegression()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" ], "text/plain": [ "LinearRegression()" ] }, - "execution_count": 21, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ - ">>> from sklearn.linear_model import LinearRegression\n", - "# Select a linear model\n", - "model = LinearRegression()\n", - "\n", "# Train the model\n", "model.fit(X, y)" ] @@ -3108,7 +3173,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 29, "id": "5278c68f", "metadata": {}, "outputs": [ @@ -3118,7 +3183,7 @@ "4.853052800266435" ] }, - "execution_count": 25, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -3131,7 +3196,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 30, "id": "7964db8c", "metadata": {}, "outputs": [ @@ -3141,7 +3206,7 @@ "array([[4.91154459e-05]])" ] }, - "execution_count": 27, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -3154,7 +3219,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 31, "id": "2c494d36", "metadata": {}, "outputs": [ @@ -3178,14 +3243,6 @@ "plt.legend()\n", "plt.show()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "714824a0", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {