updating 1-ml-landscape

online-sessions
parent a0b1841814
commit 3edb8cd51b

@ -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": [
"<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LinearRegression()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">LinearRegression</label><div class=\"sk-toggleable__content\"><pre>LinearRegression()</pre></div></div></div></div></div>"
"<style>#sk-container-id-3 {color: black;background-color: white;}#sk-container-id-3 pre{padding: 0;}#sk-container-id-3 div.sk-toggleable {background-color: white;}#sk-container-id-3 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-3 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-3 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-3 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-3 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-3 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-3 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-3 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-3 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-3 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-3 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-3 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-3 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-3 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-3 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-3 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-3 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-3 div.sk-item {position: relative;z-index: 1;}#sk-container-id-3 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-3 div.sk-item::before, #sk-container-id-3 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-3 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-3 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-3 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-3 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-3 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-3 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-3 div.sk-label-container {text-align: center;}#sk-container-id-3 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-3 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-3\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LinearRegression()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-3\" type=\"checkbox\" checked><label for=\"sk-estimator-id-3\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">LinearRegression</label><div class=\"sk-toggleable__content\"><pre>LinearRegression()</pre></div></div></div></div></div>"
],
"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": {

Loading…
Cancel
Save