├── README.md ├── .DS_Store ├── Descargar_video_de_Youtube_con_Python.ipynb ├── Prueba_t_student.ipynb ├── LICENSE ├── prueba.ipynb ├── WOE y IV.ipynb └── Convertir variables categóricas en numéricas.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # Python -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narencastellon/Python/HEAD/.DS_Store -------------------------------------------------------------------------------- /Descargar_video_de_Youtube_con_Python.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "view-in-github", 7 | "colab_type": "text" 8 | }, 9 | "source": [ 10 | "\"Open" 11 | ] 12 | }, 13 | { 14 | "cell_type": "markdown", 15 | "id": "b79b4b77-1c60-487e-9adb-cd69ce442534", 16 | "metadata": { 17 | "tags": [], 18 | "id": "b79b4b77-1c60-487e-9adb-cd69ce442534" 19 | }, 20 | "source": [ 21 | "
" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "id": "85c57df5-eb19-4bb3-9574-562f3e6e946d", 28 | "metadata": { 29 | "id": "85c57df5-eb19-4bb3-9574-562f3e6e946d" 30 | }, 31 | "outputs": [], 32 | "source": [ 33 | "from pytube import YouTube" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": null, 39 | "id": "28271c41-5457-492f-8e6a-232b337a7436", 40 | "metadata": { 41 | "id": "28271c41-5457-492f-8e6a-232b337a7436", 42 | "outputId": "bc891485-c335-4e1d-b920-5a95f652c438" 43 | }, 44 | "outputs": [ 45 | { 46 | "name": "stdin", 47 | "output_type": "stream", 48 | "text": [ 49 | "ingrese la Url del video que desea descargar: https://www.youtube.com/watch?v=UR6hc_0fpE0&t=3s\n" 50 | ] 51 | } 52 | ], 53 | "source": [ 54 | "link=input(\"ingrese la Url del video que desea descargar:\")\n" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": null, 60 | "id": "74090ad9-7530-4250-ab25-5473f25df451", 61 | "metadata": { 62 | "id": "74090ad9-7530-4250-ab25-5473f25df451", 63 | "outputId": "af35aa69-3bad-4e53-f28c-da7ae2b69233" 64 | }, 65 | "outputs": [ 66 | { 67 | "name": "stderr", 68 | "output_type": "stream", 69 | "text": [ 70 | "C:\\Users\\naren\\AppData\\Local\\Temp/ipykernel_11676/3096764175.py:4: DeprecationWarning: Call to deprecated function all (This object can be treated as a list, all() is useless).\n", 71 | " videos=yt.streams.all()\n" 72 | ] 73 | } 74 | ], 75 | "source": [ 76 | "yt=YouTube(link)\n", 77 | "\n", 78 | "#esto transmitirá todos los formularios disponibles para el video\n", 79 | "videos=yt.streams.all()" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "id": "344d988f-49be-4adf-97f7-728d3e7aa4c0", 86 | "metadata": { 87 | "id": "344d988f-49be-4adf-97f7-728d3e7aa4c0", 88 | "outputId": "dddadfbb-ac13-427f-85d8-9290c6be221e" 89 | }, 90 | "outputs": [ 91 | { 92 | "name": "stdout", 93 | "output_type": "stream", 94 | "text": [ 95 | "(0, )\n", 96 | "(1, )\n", 97 | "(2, )\n", 98 | "(3, )\n", 99 | "(4, )\n", 100 | "(5, )\n", 101 | "(6, )\n", 102 | "(7, )\n", 103 | "(8, )\n", 104 | "(9, )\n", 105 | "(10, )\n", 106 | "(11, )\n" 107 | ] 108 | } 109 | ], 110 | "source": [ 111 | "video=list(enumerate(videos))\n", 112 | "#esto indexará todo el formato en la lista comenzando con cero\n", 113 | "for i in video:\n", 114 | " print(i)\n", 115 | " #Esto imprimirá todo el formato de video disponible con el índice adecuado.\n" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": null, 121 | "id": "09b54e8f-1e70-4022-af0a-43d420061d30", 122 | "metadata": { 123 | "id": "09b54e8f-1e70-4022-af0a-43d420061d30" 124 | }, 125 | "outputs": [], 126 | "source": [ 127 | "" 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": null, 133 | "id": "2d376138-b5bb-4af9-9481-ba98303440ee", 134 | "metadata": { 135 | "id": "2d376138-b5bb-4af9-9481-ba98303440ee", 136 | "outputId": "ec2faeff-4e6b-41ea-8a2f-f9b23ab3e170" 137 | }, 138 | "outputs": [ 139 | { 140 | "name": "stdout", 141 | "output_type": "stream", 142 | "text": [ 143 | "ingrese la opción deseada para descargar el formato\n" 144 | ] 145 | }, 146 | { 147 | "name": "stdin", 148 | "output_type": "stream", 149 | "text": [ 150 | "ingrese la opción: 3\n" 151 | ] 152 | } 153 | ], 154 | "source": [ 155 | "print(\"ingrese la opción deseada para descargar el formato\")\n", 156 | "dn_opcion=int(input(\"ingrese la opción:\"))\n", 157 | "\n" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": null, 163 | "id": "b7c9e26c-7090-4b5f-ae81-90c01a826edc", 164 | "metadata": { 165 | "id": "b7c9e26c-7090-4b5f-ae81-90c01a826edc", 166 | "outputId": "f4780d88-b703-497b-bd35-0ff5e37e5c74" 167 | }, 168 | "outputs": [ 169 | { 170 | "name": "stdout", 171 | "output_type": "stream", 172 | "text": [ 173 | "La descarga fue correcta\n" 174 | ] 175 | } 176 | ], 177 | "source": [ 178 | "dn_video=videos[dn_opcion]\n", 179 | "\n", 180 | "dn_video.download()\n", 181 | "\n", 182 | "print(\"La descarga fue correcta\")" 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "execution_count": null, 188 | "id": "a1f0703e-2760-40e2-be33-20bc233b905b", 189 | "metadata": { 190 | "id": "a1f0703e-2760-40e2-be33-20bc233b905b" 191 | }, 192 | "outputs": [], 193 | "source": [ 194 | "" 195 | ] 196 | } 197 | ], 198 | "metadata": { 199 | "kernelspec": { 200 | "display_name": "Python 3 (ipykernel)", 201 | "language": "python", 202 | "name": "python3" 203 | }, 204 | "language_info": { 205 | "codemirror_mode": { 206 | "name": "ipython", 207 | "version": 3 208 | }, 209 | "file_extension": ".py", 210 | "mimetype": "text/x-python", 211 | "name": "python", 212 | "nbconvert_exporter": "python", 213 | "pygments_lexer": "ipython3", 214 | "version": "3.9.9" 215 | }, 216 | "colab": { 217 | "name": "Descargar video de Youtube con Python.ipynb", 218 | "provenance": [], 219 | "include_colab_link": true 220 | } 221 | }, 222 | "nbformat": 4, 223 | "nbformat_minor": 5 224 | } -------------------------------------------------------------------------------- /Prueba_t_student.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Prueba t-student.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "authorship_tag": "ABX9TyNgGKkfVkk7PY60/adF5558", 10 | "include_colab_link": true 11 | }, 12 | "kernelspec": { 13 | "name": "python3", 14 | "display_name": "Python 3" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": { 31 | "id": "m_8_b5yzB8RF" 32 | }, 33 | "source": [ 34 | "# **Prueba $t$ de una muestra**\r\n", 35 | "* La prueba $t$ de una muestra se utiliza para comparar la media muestral (una muestra aleatoria de una población) con el valor específico (media hipotética o conocida de la población).\r\n", 36 | "* Por ejemplo, una bola tiene un diámetro de 5 cm y queremos comprobar si el diámetro medio de la bola de la muestra aleatoria (por ejemplo, 50 bolas) recogida de la línea de producción difiere del tamaño conocido." 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": { 42 | "id": "dobc06AMCOz-" 43 | }, 44 | "source": [ 45 | "# **Supuestos**\r\n", 46 | "* La variable dependiente debe tener una distribución aproximadamente normal (prueba de Shapiro-Wilks)\r\n", 47 | "* Las observaciones son independientes entre sí" 48 | ] 49 | }, 50 | { 51 | "cell_type": "markdown", 52 | "metadata": { 53 | "id": "UBjnpMxICbp3" 54 | }, 55 | "source": [ 56 | "# **Hipótesis**\r\n", 57 | "* **Hipótesis nula :** la media de la muestra es igual a la media de la población hipotética o conocida\r\n", 58 | "* **Hipótesis alternativa :** la media de la muestra no es igual a la media de la población hipotética o conocida (de dos colas o de dos lados)\r\n", 59 | "* **Hipótesis alternativa :** la media de la muestra es mayor o menor que la media de la población hipotetizada o conocida ( unilateral o unilateral )" 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "metadata": { 65 | "id": "VnNMBVATCtY8" 66 | }, 67 | "source": [ 68 | "# **Fórmula**\r\n", 69 | "$$\\it{t} = \\frac{ \\bar{x} - \\mu }{ s / \\sqrt{n} }$$\r\n", 70 | "\r\n", 71 | "Sigue aproximadamente $t$-distribución con $n-1$ grados de libertad\r\n", 72 | "\r\n", 73 | "Dónde, \r\n", 74 | "\r\n", 75 | "$X=$ media muestral; \\\r\n", 76 | "$\\mu=$ media poblacional hipotética o conocida; \\\r\n", 77 | "$s=$ desviación estándar de la muestra y \\\r\n", 78 | "$n=$ es el tamaño de la muestra" 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "metadata": { 84 | "id": "UMpgPpk_X3nX" 85 | }, 86 | "source": [ 87 | "# **¿Cómo realizar una prueba t de muestra en Python?**" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "metadata": { 93 | "id": "RHepB8gHYRS9" 94 | }, 95 | "source": [ 96 | "!pip install bioinfokit" 97 | ], 98 | "execution_count": null, 99 | "outputs": [] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "metadata": { 104 | "colab": { 105 | "base_uri": "https://localhost:8080/", 106 | "height": 204 107 | }, 108 | "id": "whzrGD9zBk7Q", 109 | "outputId": "785ec1f7-8e6f-46ab-ef1f-66a3672d71f8" 110 | }, 111 | "source": [ 112 | "from bioinfokit.analys import get_data, stat\r\n", 113 | "# load dataset as pandas dataframe\r\n", 114 | "# the dataset should not have missing (NaN) values. If it has, it will omitted\r\n", 115 | "df = get_data('t_one_samp').data\r\n", 116 | "df.head()" 117 | ], 118 | "execution_count": null, 119 | "outputs": [ 120 | { 121 | "output_type": "execute_result", 122 | "data": { 123 | "text/html": [ 124 | "
\n", 125 | "\n", 138 | "\n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | "
size
05.739987
15.254042
25.152388
34.870819
43.536251
\n", 168 | "
" 169 | ], 170 | "text/plain": [ 171 | " size\n", 172 | "0 5.739987\n", 173 | "1 5.254042\n", 174 | "2 5.152388\n", 175 | "3 4.870819\n", 176 | "4 3.536251" 177 | ] 178 | }, 179 | "metadata": { 180 | "tags": [] 181 | }, 182 | "execution_count": 6 183 | } 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "metadata": { 189 | "colab": { 190 | "base_uri": "https://localhost:8080/" 191 | }, 192 | "id": "n2wWKIBFYizL", 193 | "outputId": "90351c58-b4b7-4897-bc53-fce5c58cb008" 194 | }, 195 | "source": [ 196 | "res = stat()\r\n", 197 | "res.ttest(df=df, test_type=1, res='size', mu=5)\r\n", 198 | "print(res.summary)" 199 | ], 200 | "execution_count": null, 201 | "outputs": [ 202 | { 203 | "output_type": "stream", 204 | "text": [ 205 | "\n", 206 | "One Sample t-test \n", 207 | "\n", 208 | "------------------ --------\n", 209 | "Sample size 50\n", 210 | "Mean 5.05128\n", 211 | "t 0.36789\n", 212 | "Df 49\n", 213 | "P-value (one-tail) 0.35727\n", 214 | "P-value (two-tail) 0.71454\n", 215 | "Lower 95.0% 4.77116\n", 216 | "Upper 95.0% 5.3314\n", 217 | "------------------ --------\n" 218 | ], 219 | "name": "stdout" 220 | } 221 | ] 222 | }, 223 | { 224 | "cell_type": "markdown", 225 | "metadata": { 226 | "id": "vvuqLkfBYs9U" 227 | }, 228 | "source": [ 229 | "# **Interpretación**\r\n", 230 | "El valor $p$ obtenido de la prueba $t$ de una muestra no es significativo $(p> 0.05)$, y por lo tanto, concluimos que el diámetro promedio de las bolas en una muestra aleatoria es igual a 5 cm." 231 | ] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "metadata": { 236 | "id": "ZVlei7GkY6Jh" 237 | }, 238 | "source": [ 239 | "# **Prueba t de dos muestras (prueba t independiente o no apareada )**\r\n", 240 | "* Prueba $t$ independiente de dos muestras Se utiliza para comparar las medias de dos grupos independientes\r\n", 241 | "* Por ejemplo, tenemos dos genotipos de plantas diferentes (genotipo A y genotipo B) y nos gustaría comparar si el rendimiento del genotipo A es significativamente diferente del genotipo B" 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": { 247 | "id": "qfmmeC5FZHaX" 248 | }, 249 | "source": [ 250 | "# **Dos hipótesis de prueba t de muestra**\r\n", 251 | "* **Hipótesis nula :** las medias de dos grupos son iguales\r\n", 252 | "* **Hipótesis alternativa :** las medias de dos grupos son diferentes (de dos colas o de dos caras)\r\n", 253 | "* **Hipótesis alternativa :** media de un grupo mayor o menor que otro grupo (unilateral o unilateral)" 254 | ] 255 | }, 256 | { 257 | "cell_type": "markdown", 258 | "metadata": { 259 | "id": "n7deue23ZVyv" 260 | }, 261 | "source": [ 262 | "# **Supuestos de prueba t de muestra**\r\n", 263 | "* Las observaciones en dos grupos tienen una distribución aproximadamente normal (prueba de Shapiro-Wilks)\r\n", 264 | "* Homogeneidad de varianzas (las varianzas son iguales entre los grupos de tratamiento) (prueba de Levene o Bartlett)\r\n", 265 | "* Los dos grupos se muestrean de forma independiente entre sí de la misma población" 266 | ] 267 | }, 268 | { 269 | "cell_type": "markdown", 270 | "metadata": { 271 | "id": "royCaHiHZjPn" 272 | }, 273 | "source": [ 274 | "# **Fórmula**\r\n", 275 | "$$\\it{t} = \\frac{ \\bar{x_1} - \\bar{x_2} }{ \\sqrt{s^2 (\\frac{1}{n_1} + \\frac{1}{n_2}) } }$$\r\n", 276 | "\r\n", 277 | "Sigue aproximadamente $t$- distribución con $n_1+n_2-1$\r\n", 278 | " grados de libertad\r\n", 279 | "\r\n", 280 | "Dónde,\r\n", 281 | " \r\n", 282 | "$\\bar x_1$ y $\\bar x_2=$ medias para dos muestras independientes; \\\r\n", 283 | "$s^2=$ varianza de la muestra combinada (estimación de la varianza de la \\población desconocida $\\sigma^2$), y \\\r\n", 284 | "$n_1$ y $n_2=$ son el tamaño de la muestra para dos muestras independientes" 285 | ] 286 | }, 287 | { 288 | "cell_type": "markdown", 289 | "metadata": { 290 | "id": "rgBL-q8Na_ZA" 291 | }, 292 | "source": [ 293 | "$s^2$ es calculado como:\r\n", 294 | "$$\\it{s^2} = \\frac{ (n_1-1) s_{x_1}^2 + (n_2-1) s_{x_2}^2 }{ n_1+n_2-2 }$$\r\n", 295 | "donde\r\n", 296 | "$s_{x_1}^2$ y $s_{x_2}^2$ varianzas muestrales (estimación de varianzas poblacionales desconocidas $\\sigma_{x_1}^2$ y $\\sigma_{x_2}^2$\r\n", 297 | "\r\n", 298 | "Para la prueba de Welch (donde las variaciones de grupo no son iguales)\r\n", 299 | "\r\n", 300 | "$$\\it{t} = \\frac{ \\mid \\bar{x_1} - \\bar{x_2} \\mid }{ \\sqrt{ \\frac{s_{x_1}^2}{n_1} + \\frac{s_{x_2}^2}{n_2} } }$$\r\n", 301 | "\r\n", 302 | "Sigue aproximadamente $t$- distribución con $v$ grados de libertad\r\n", 303 | "\r\n", 304 | "$$\\nu = \\frac{ (s_{x_1}^2/n_1 + s_{x_2}^2/n_2)^2 }{ \\frac{ (s_{x_1}^2/n_1)^2 }{n_1-1} + \\frac{ (s_{x_2}^2/n_2)^2 }{n_2-1} }$$" 305 | ] 306 | }, 307 | { 308 | "cell_type": "markdown", 309 | "metadata": { 310 | "id": "iw8131zvcwCh" 311 | }, 312 | "source": [ 313 | "# **¿Cómo realizar dos pruebas t de muestra en Python?**" 314 | ] 315 | }, 316 | { 317 | "cell_type": "code", 318 | "metadata": { 319 | "colab": { 320 | "base_uri": "https://localhost:8080/", 321 | "height": 204 322 | }, 323 | "id": "vw8YG94scqR3", 324 | "outputId": "efe6b043-93b5-42c0-bbb6-8d86b8e872b9" 325 | }, 326 | "source": [ 327 | "from bioinfokit.analys import get_data, stat\r\n", 328 | "# Cargamos la data con pandas dataframe\r\n", 329 | "# el conjunto de datos no debe tener valores perdidos (NaN). Si lo ha hecho, se omitirá\r\n", 330 | "df = get_data('t_ind_samp').data\r\n", 331 | "df.head()" 332 | ], 333 | "execution_count": null, 334 | "outputs": [ 335 | { 336 | "output_type": "execute_result", 337 | "data": { 338 | "text/html": [ 339 | "
\n", 340 | "\n", 353 | "\n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | " \n", 367 | " \n", 368 | " \n", 369 | " \n", 370 | " \n", 371 | " \n", 372 | " \n", 373 | " \n", 374 | " \n", 375 | " \n", 376 | " \n", 377 | " \n", 378 | " \n", 379 | " \n", 380 | " \n", 381 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | "
Genotypeyield
0A78.0
1A84.3
2A81.0
3B88.0
4B92.0
\n", 389 | "
" 390 | ], 391 | "text/plain": [ 392 | " Genotype yield\n", 393 | "0 A 78.0\n", 394 | "1 A 84.3\n", 395 | "2 A 81.0\n", 396 | "3 B 88.0\n", 397 | "4 B 92.0" 398 | ] 399 | }, 400 | "metadata": { 401 | "tags": [] 402 | }, 403 | "execution_count": 8 404 | } 405 | ] 406 | }, 407 | { 408 | "cell_type": "code", 409 | "metadata": { 410 | "colab": { 411 | "base_uri": "https://localhost:8080/" 412 | }, 413 | "id": "U3Ga4pcydBzc", 414 | "outputId": "d2c17cc2-683d-4b32-ffbc-bee93a8df26a" 415 | }, 416 | "source": [ 417 | "res = stat()\r\n", 418 | "# para la prueba t de varianza desigual (prueba t de Welch), establezca evar = Falso\r\n", 419 | "res.ttest(df=df, xfac=\"Genotype\", res=\"yield\", test_type=2)\r\n", 420 | "print(res.summary)" 421 | ], 422 | "execution_count": null, 423 | "outputs": [ 424 | { 425 | "output_type": "stream", 426 | "text": [ 427 | "\n", 428 | "Two sample t-test with equal variance\n", 429 | "\n", 430 | "------------------ -------------\n", 431 | "Mean diff -10.3\n", 432 | "t -5.40709\n", 433 | "Std Error 1.90491\n", 434 | "df 10\n", 435 | "P-value (one-tail) 0.000149204\n", 436 | "P-value (two-tail) 0.000298408\n", 437 | "Lower 95.0% -14.5444\n", 438 | "Upper 95.0% -6.05561\n", 439 | "------------------ -------------\n", 440 | "\n", 441 | "Parameter estimates\n", 442 | "\n", 443 | "Level Number Mean Std Dev Std Error Lower 95.0% Upper 95.0%\n", 444 | "------- -------- ------ --------- ----------- ------------- -------------\n", 445 | "A 6 79.1 3.30817 1.35056 75.6283 82.5717\n", 446 | "B 6 89.4 3.29059 1.34338 85.9467 92.8533\n", 447 | "\n" 448 | ], 449 | "name": "stdout" 450 | } 451 | ] 452 | }, 453 | { 454 | "cell_type": "markdown", 455 | "metadata": { 456 | "id": "1UB4BhLOdOMO" 457 | }, 458 | "source": [ 459 | "**Nota :** Aunque puede realizar una prueba t cuando el tamaño de la muestra es desigual entre dos grupos, es más eficiente tener un tamaño de muestra igual en dos grupos para aumentar la potencia de la prueba t .\r\n", 460 | "\r\n", 461 | "**Interpretación**\r\n", 462 | "El valor de p obtenido de la prueba t es significativo ( p <0.05), por lo que concluimos que el rendimiento del genotipo A es significativamente diferente al del genotipo B." 463 | ] 464 | }, 465 | { 466 | "cell_type": "markdown", 467 | "metadata": { 468 | "id": "vbh1te17dYPL" 469 | }, 470 | "source": [ 471 | "# **Prueba $t$ pareada ( prueba t dependiente )**\r\n", 472 | "* Prueba t pareada utilizada para comparar las diferencias entre el par de variables dependientes para el mismo sujeto\r\n", 473 | "* Por ejemplo, tenemos la variedad de planta A y nos gustaría comparar el rendimiento de A antes y después de la aplicación de algún fertilizante.\r\n", 474 | "* Nota : Paired $t -test$ es una muestra de un $t -test$ sobre las diferencias entre las dos variables dependientes" 475 | ] 476 | }, 477 | { 478 | "cell_type": "markdown", 479 | "metadata": { 480 | "id": "hGc84DNgdnmB" 481 | }, 482 | "source": [ 483 | "# **Prueba de hipótesis de t-Pariada**\r\n", 484 | "* **Hipótesis nula :** no hay diferencia entre las dos variables dependientes (diferencia = 0)\r\n", 485 | "* **Hipótesis alternativa :** hay una diferencia entre las dos variables dependientes (de dos colas o de dos caras)\r\n", 486 | "* **Hipótesis alternativa :** diferencia entre dos variables de respuesta mayor o menor que cero ( unilateral o unilateral )" 487 | ] 488 | }, 489 | { 490 | "cell_type": "markdown", 491 | "metadata": { 492 | "id": "ZYGeeom7d02P" 493 | }, 494 | "source": [ 495 | "# **Emparejado t Supuestos**\r\n", 496 | "* Las diferencias entre las dos variables dependientes siguen una distribución aproximadamente normal (prueba de Shapiro-Wilks)\r\n", 497 | "* La variable independiente debe tener un par de variables dependientes\r\n", 498 | "* Las diferencias entre las dos variables dependientes no deben tener valores atípicos\r\n", 499 | "* Las observaciones se muestrean independientemente unas de otras." 500 | ] 501 | }, 502 | { 503 | "cell_type": "markdown", 504 | "metadata": { 505 | "id": "7LCaDMe4d89h" 506 | }, 507 | "source": [ 508 | "# **Fórmula**\r\n", 509 | "\r\n", 510 | "$$\\it{t} = \\frac{ \\bar{d} }{ s_d / \\sqrt{n} }$$\r\n", 511 | "\r\n", 512 | "Sigue aproximadamente $t$ -distribución con $n-1$ grados de libertad\r\n", 513 | "\r\n", 514 | "Dónde, \r\n", 515 | "\r\n", 516 | "$\\bar d=$ media de las diferencias muestrales; \\\r\n", 517 | "$s_d=$ desviación estándar de las diferencias muestrales y \\\r\n", 518 | "$n=$ es el tamaño de la muestra" 519 | ] 520 | }, 521 | { 522 | "cell_type": "code", 523 | "metadata": { 524 | "colab": { 525 | "base_uri": "https://localhost:8080/", 526 | "height": 204 527 | }, 528 | "id": "9itY0Dcde1EP", 529 | "outputId": "97374fe5-04df-432a-9fc4-0744d7fa559a" 530 | }, 531 | "source": [ 532 | "from bioinfokit.analys import get_data, stat\r\n", 533 | "# Cargamo la data con pandas dataframe\r\n", 534 | "# el conjunto de datos no debe tener valores perdidos (NaN). Si lo ha hecho, se omitirá\r\n", 535 | "df = get_data('t_pair').data\r\n", 536 | "df.head()" 537 | ], 538 | "execution_count": null, 539 | "outputs": [ 540 | { 541 | "output_type": "execute_result", 542 | "data": { 543 | "text/html": [ 544 | "
\n", 545 | "\n", 558 | "\n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | "
BFAF
044.4147.99
146.2956.64
245.9848.90
343.3549.01
445.7548.41
\n", 594 | "
" 595 | ], 596 | "text/plain": [ 597 | " BF AF\n", 598 | "0 44.41 47.99\n", 599 | "1 46.29 56.64\n", 600 | "2 45.98 48.90\n", 601 | "3 43.35 49.01\n", 602 | "4 45.75 48.41" 603 | ] 604 | }, 605 | "metadata": { 606 | "tags": [] 607 | }, 608 | "execution_count": 10 609 | } 610 | ] 611 | }, 612 | { 613 | "cell_type": "code", 614 | "metadata": { 615 | "colab": { 616 | "base_uri": "https://localhost:8080/" 617 | }, 618 | "id": "vq99MOwXfAuh", 619 | "outputId": "348475d0-3259-40da-f408-fe3a38284523" 620 | }, 621 | "source": [ 622 | "res = stat()\r\n", 623 | "res.ttest(df=df, res=['AF', 'BF'], test_type=3)\r\n", 624 | "print(res.summary)" 625 | ], 626 | "execution_count": null, 627 | "outputs": [ 628 | { 629 | "output_type": "stream", 630 | "text": [ 631 | "\n", 632 | "Paired t-test \n", 633 | "\n", 634 | "------------------ ------------\n", 635 | "Sample size 65\n", 636 | "Difference Mean 5.55262\n", 637 | "t 14.2173\n", 638 | "Df 64\n", 639 | "P-value (one-tail) 8.87966e-22\n", 640 | "P-value (two-tail) 1.77593e-21\n", 641 | "Lower 95.0% 4.7724\n", 642 | "Upper 95.0% 6.33283\n", 643 | "------------------ ------------\n" 644 | ], 645 | "name": "stdout" 646 | } 647 | ] 648 | }, 649 | { 650 | "cell_type": "markdown", 651 | "metadata": { 652 | "id": "3vpUO3wHfGBg" 653 | }, 654 | "source": [ 655 | "# **Interpretación**\r\n", 656 | "El valor $p$ obtenido a partir de la prueba $t$ es significativo $( p <0.05)$, por lo que concluimos que el rendimiento de la variedad vegetal A aumentó significativamente con la aplicación de fertilizante." 657 | ] 658 | } 659 | ] 660 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | , 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! 505 | -------------------------------------------------------------------------------- /prueba.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "prueba.ipynb", 7 | "provenance": [], 8 | "toc_visible": true, 9 | "authorship_tag": "ABX9TyN4sfJ4Q1r6LM7vWMNyryDt", 10 | "include_colab_link": true 11 | }, 12 | "kernelspec": { 13 | "name": "python3", 14 | "display_name": "Python 3" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": { 31 | "id": "r6WhQ_QCtgvX" 32 | }, 33 | "source": [ 34 | "#Títulos\n", 35 | "#Python Colab\n", 36 | "## Ejemplos Python\n", 37 | "### Viñetas\n", 38 | "#### Gráficos" 39 | ] 40 | }, 41 | { 42 | "cell_type": "markdown", 43 | "metadata": { 44 | "id": "sEcfTZbtttjF" 45 | }, 46 | "source": [ 47 | "\n", 48 | "\n", 49 | "1. Frutas\n", 50 | " * manzanas\n", 51 | " * Peras\n", 52 | " * uvas\n", 53 | "\n", 54 | "2. Carros\n", 55 | " * Toyota\n", 56 | " * BMW\n", 57 | " * Mercedes Ben\n", 58 | "\n" 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": { 64 | "id": "DFsEKR0VuKHP" 65 | }, 66 | "source": [ 67 | "Usamos latex incluido en google colab\n", 68 | "\n", 69 | "$$ \\hat x_i=\\sum_{i=1}^{n} \\frac{x_i}{n} $$" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "metadata": { 75 | "colab": { 76 | "base_uri": "https://localhost:8080/" 77 | }, 78 | "id": "aKzDBfAUunHE", 79 | "outputId": "a7db6119-029b-4828-c08e-cdb8e0e51e42" 80 | }, 81 | "source": [ 82 | "a=2+6\n", 83 | "print(a)" 84 | ], 85 | "execution_count": null, 86 | "outputs": [ 87 | { 88 | "output_type": "stream", 89 | "text": [ 90 | "8\n" 91 | ], 92 | "name": "stdout" 93 | } 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "metadata": { 99 | "colab": { 100 | "base_uri": "https://localhost:8080/", 101 | "height": 142 102 | }, 103 | "id": "i2DQ4PwcuwD_", 104 | "outputId": "a734ca7d-39f5-4752-bdb7-0274f5c03d50" 105 | }, 106 | "source": [ 107 | "import pandas as pd\n", 108 | "datos = pd.DataFrame({ \"manzanas\": [3, 2,5], \"peras\" : [1,4,6] , \"Naranjas\" : [5,4,7] }, index=[\"Naren\", \"Jans\", \"Mateo\"])\n", 109 | "datos\n" 110 | ], 111 | "execution_count": null, 112 | "outputs": [ 113 | { 114 | "output_type": "execute_result", 115 | "data": { 116 | "text/html": [ 117 | "
\n", 118 | "\n", 131 | "\n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | "
manzanasperasNaranjas
Naren315
Jans244
Mateo567
\n", 161 | "
" 162 | ], 163 | "text/plain": [ 164 | " manzanas peras Naranjas\n", 165 | "Naren 3 1 5\n", 166 | "Jans 2 4 4\n", 167 | "Mateo 5 6 7" 168 | ] 169 | }, 170 | "metadata": { 171 | "tags": [] 172 | }, 173 | "execution_count": 4 174 | } 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "metadata": { 180 | "colab": { 181 | "base_uri": "https://localhost:8080/", 182 | "height": 303 183 | }, 184 | "id": "kHiGpvU2u_XF", 185 | "outputId": "fdf56027-e3e4-40d6-bd7d-f50ede9794e4" 186 | }, 187 | "source": [ 188 | "#Hacer un gráfico de barra\n", 189 | "datos.plot.bar()" 190 | ], 191 | "execution_count": null, 192 | "outputs": [ 193 | { 194 | "output_type": "execute_result", 195 | "data": { 196 | "text/plain": [ 197 | "" 198 | ] 199 | }, 200 | "metadata": { 201 | "tags": [] 202 | }, 203 | "execution_count": 5 204 | }, 205 | { 206 | "output_type": "display_data", 207 | "data": { 208 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAENCAYAAAAmKS8BAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAXw0lEQVR4nO3df5BU5Z3v8feXARlCAEuZUAhMhlur/BxmBgYSM0hQwoJCWJclUYNGV2Wqwo/gBi9gUrmit+JNsSjoLtlIQVZ0JYuyWot63StmNWJMRH4MMMDgj2SIk2X9gYogIjOT7/2je9oBB+YMdvd5Zvrzquqi+/Tpc77dDR+efs5znmPujoiIhKtT3AWIiMiZKahFRAKnoBYRCZyCWkQkcApqEZHAKahFRALXORMb7d27txcVFWVi0yIiHdK2bdvedfeClp7LSFAXFRWxdevWTGxaRKRDMrMDp3tOXR8iIoFTUIuIBE5BLSISuIz0Ubekvr6euro6jh8/nq1d5oT8/Hz69+9Ply5d4i5FRDIka0FdV1dHjx49KCoqwsyytdsOzd05dOgQdXV1DBw4MO5yRCRDWu36MLNBZlbV7Pahmd3S1h0dP36c888/XyGdRmbG+eefr18pIh1cqy1qd98PlAKYWR7wJ+Dxs9mZQjr99JmKdHxtPZg4AXjD3U873k9ERNKrrX3UVwO/bOkJM6sEKgEKCwtb3VDR4qfauOszq/3plLRuT0Tap+K1xWnZzu7rd6dlO+kQuUVtZucA04BHW3re3Ve5e7m7lxcUtHgWZKxqa2sZPHgwN9xwAxdddBEzZ87k2WefpaKiggsvvJAtW7awZcsWLr74YsrKyvja177G/v37A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xsw2Ah81LdSZicH7wMy+SOJMtofN7G2afX8SvP8CtgLTSJy01OQI8HexVBQTdX1EYGa3t7Tc3e/Idi0SnZl9AThO4rjCtSRaYg+7+3uxFiZtYmZd3L0+7jripKCWDsfMjvDZ0R1NYyuPA28AP3L3X2W1MDkrySF5/wcYCuQ3LXf3/xFbUVmmro8IzKwAWEhiiFDzvyiXxVaUnJa79zjdc8mDw8OBh5N/Svj+mcTZicuBS4G/JceGFufUm/0cHiZx+vhA4A4Scxy/EmdBcnbcvTF5Zuk/xF2LRNYt+evHkmPjlwBTYq4pqxTU0Zzv7mtIjCL4dXIeXLWm2zF3vz/uGiSyT8ysE/Camc01s78Gvhh3UdmkoI6m6UDGQTObYmZlwHlxFiSSQ+YDXyBx6vgoEte9vD7WirJMBxMjMLOpJIZ4DSDxk7kncIe7b4y1MBHJCQpqEQlS8ryF08ql+ag16uMMzOx/neFpd/f/nbViRHLPxcCbJK44/jKfDrHMOWpRn4GZLWhhcXfgJhIHGHPqgIZINiWHUk4ErgFGkLhm6S/dfU+shcVAQR2RmfUgcVDjJuAR4G53fzveqkRyQ/ICt9eQuCTXHe7+jzGXlFXq+miFmZ0H/IDEJerXAiPd/f14qxLJDcmAnkIipIuA+4DH46wpDgrqMzCzvwemA6uAYnc/GnNJIjnDzB4kcfbo/yXRiq6OuaTYqOvjDMzszySuKtHAyXNHGImDiT1jKUwkByT//TXNdpjT//4U1CIigdOZiSIigVNQi4gETkEtIhI4BbWISOAU1CIigfv/N8HiqFaAQY4AAAAASUVORK5CYII=\n", 209 | "text/plain": [ 210 | "
" 211 | ] 212 | }, 213 | "metadata": { 214 | "tags": [], 215 | "needs_background": "light" 216 | } 217 | } 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "metadata": { 223 | "colab": { 224 | "base_uri": "https://localhost:8080/", 225 | "height": 265 226 | }, 227 | "id": "eRTHJYD3vL33", 228 | "outputId": "4d2e8776-b337-4451-dac5-43fea2d1bf43" 229 | }, 230 | "source": [ 231 | "#grafico de paste, circular o pie chart\n", 232 | "datos[\"frutas en total\"]= datos[\"manzanas\"] + datos[\"peras\"]\n", 233 | "datos.plot.pie( y=\"frutas en total\", autopct='%1.1f%%')" 234 | ], 235 | "execution_count": null, 236 | "outputs": [ 237 | { 238 | "output_type": "execute_result", 239 | "data": { 240 | "text/plain": [ 241 | "" 242 | ] 243 | }, 244 | "metadata": { 245 | "tags": [] 246 | }, 247 | "execution_count": 6 248 | }, 249 | { 250 | "output_type": "display_data", 251 | "data": { 252 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPYAAADnCAYAAAAtmKv2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3deXhU1fnA8e+ZmewkQ5CdBMIWSGRYtBVFq1UBF8S6UReqsRXX1tq6YvVXp9YqKi5V24q01lRKa22rQtGqtbgvFRG4KjsEwmZCQjaSzPr+/rgTCJBlsszcycz5PM88Tmbunfsm8s6599xz3qNEBE3T4ovN6gA0Tet+OrE1LQ7pxNa0OKQTW9PikE5sTYtDOrE1LQ7pxNa0OKQTW9PikE5sTYtDOrE1LQ45rA5A01rz2Wef9Xc4HL8HxpG4jVAQ+MLv98859thjy8LdSSe2FrMcDsfvBw4cWNCvX799NpstISc1BINBVV5eXrhnz57fA+eGu1+ifgtqPcO4fv361SRqUgPYbDbp169fNeZZS/j7RSgeTesOtkRO6iahv0GHclUntqbFIX2NrfUYeXOXHdudn1cyb8Zn7W2jlDp2zpw5Xy9cuHAHwM9//vMBdXV19kcffXRXd8bS3XSLrWltSE5OlldffTV79+7dnWoEfT5fd4cUFp3YmtYGu90uV1xxRfn9998/4PD3Fi9e7Bw/fvzYgoKCwilTpuSXlpY6AG6++ebB55133vBjjjlm7AUXXDB8165djjPOOGPkuHHjCsaNG1fwx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262 | }, 263 | { 264 | "cell_type": "markdown", 265 | "metadata": { 266 | "id": "rqFWarTLxA0d" 267 | }, 268 | "source": [ 269 | "Mi Canal de youtube es Naren Castellon\n", 270 | "
\n", 271 | "
\n", 272 | "\n" 273 | ] 274 | }, 275 | { 276 | "cell_type": "code", 277 | "metadata": { 278 | "colab": { 279 | "base_uri": "https://localhost:8080/", 280 | "height": 400 281 | }, 282 | "id": "MPBQA2kUxC6Z", 283 | "outputId": "edbf3cc9-3b6f-447b-e534-87b610cdf7da" 284 | }, 285 | "source": [ 286 | "#@title Give me a name {display-mode: \"form\"}\n", 287 | "%%html\n", 288 | "Mi Canal de youtube es Naren Castellon\n", 289 | "
\n", 290 | "
\n", 291 | "\n" 292 | ], 293 | "execution_count": null, 294 | "outputs": [ 295 | { 296 | "output_type": "display_data", 297 | "data": { 298 | "text/html": [ 299 | "Mi Canal de youtube es Naren Castellon\n", 300 | "
\n", 301 | "
\n", 302 | "" 303 | ], 304 | "text/plain": [ 305 | "" 306 | ] 307 | }, 308 | "metadata": { 309 | "tags": [] 310 | } 311 | } 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "metadata": { 317 | "id": "1PzpSs6Oyb1R" 318 | }, 319 | "source": [ 320 | "" 321 | ], 322 | "execution_count": null, 323 | "outputs": [] 324 | } 325 | ] 326 | } -------------------------------------------------------------------------------- /WOE y IV.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "26b4b504-3a2e-4ec9-8c89-8d4d000d7b93", 6 | "metadata": {}, 7 | "source": [] 8 | }, 9 | { 10 | "cell_type": "markdown", 11 | "id": "1346ab17-450e-412a-aaf4-5f39ec98b3c2", 12 | "metadata": {}, 13 | "source": [ 14 | "# Peso de la evidencia y valor de la información usando Python\n", 15 | "\n", 16 | "Por: Naren Castellon" 17 | ] 18 | }, 19 | { 20 | "cell_type": "markdown", 21 | "id": "7f5c08f5-d8bf-43db-979f-964a966873f3", 22 | "metadata": {}, 23 | "source": [ 24 | "El peso de la evidencia (WOE) [Weight of evidence] y el valor de la información (IV) [Information value]son técnicas simples pero poderosas para realizar la transformación y selección de variables. Estos conceptos tienen una gran conexión con la técnica de modelado de regresión logística. Es ampliamente utilizado en la calificación crediticia para medir la separación de clientes buenos y malos.\n", 25 | "\n", 26 | "La fórmula para calcular WOE y IV se proporciona a continuación.\n", 27 | "\n", 28 | "$$WOE=ln(\\frac{\\%Event}{No Event\\%}) $$\n", 29 | "y\n", 30 | "$$IV=\\sum (\\%Event - No Event\\%) \\times ln(\\frac{\\%Event}{No Event\\%}) $$\n", 31 | "o simplemente\n", 32 | "$$IV=\\sum (\\%Event - No Event\\%) \\times WOE $$\n" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "id": "1d0807ca-e23c-4e64-b029-5ea437820647", 38 | "metadata": {}, 39 | "source": [ 40 | "## Las ventajas de la transformación WOE son\n", 41 | "1. Controla los valores que faltan\n", 42 | "2. Maneja valores atípicos\n", 43 | "3. La transformación se basa en el valor logarítmico de las distribuciones. Esto está alineado con la función de salida de regresión logística\n", 44 | "4. No hay necesidad de variables ficticias\n", 45 | "5. Mediante el uso de la técnica de binning adecuada, puede establecer una relación monótona (ya sea aumento o disminución) entre la variable independiente y dependiente." 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "id": "3af86d49-54a6-4c53-ae2b-4261ea3ca8d4", 51 | "metadata": {}, 52 | "source": [ 53 | "Además, el valor IV se puede utilizar para seleccionar variables rápidamente.\n", 54 | "\n", 55 | "|Información value| Predicción|\n", 56 | "|-----------------|-----------|\n", 57 | "|<0.02 |inútil para la predicción|\n", 58 | "|0.02 a 0.1 |predictor débil|\n", 59 | "|0.1 a 0.3 |predictor medio|\n", 60 | "|0.3 a 0.5 |predictor fuerte|\n", 61 | "|>0.5 |Sospechoso o demasiado bueno para ser verdad|\n", 62 | "\n" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "id": "d6e25bf8-2c4d-43d8-bde6-8143bb4b8c03", 68 | "metadata": {}, 69 | "source": [ 70 | "Por convención los valores de la estadística IV en la calificación crediticia pueden interpretarse de la siguiente manera.\n", 71 | "\n", 72 | "Si la estadística IV es:\n", 73 | "1. Menos de 0.02, entonces el predictor no es útil para el modelado (separando los Bienes de los Malos)\n", 74 | "2. 0.02 a 0.1, entonces el predictor solo tiene una relación débil con la relación de probabilidades Bienes/Malos\n", 75 | "3. 0.1 a 0.3, entonces el predictor tiene una relación de fuerza media con la relación de probabilidades Bienes/Malos\n", 76 | "4. 0.3 a 0.5, entonces el predictor tiene una fuerte relación con la relación de probabilidades Bienes/Malos.\n", 77 | "5. $> 0.5$, relación sospechosa" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "id": "5557f166-7f70-4ea5-a969-09c6fffc626f", 83 | "metadata": {}, 84 | "source": [ 85 | "## Puntos importantes\n", 86 | "1. El valor de la información aumenta a medida que aumentan los contenedores / grupos para una variable independiente. Tenga cuidado cuando haya más de 20 contenedores, ya que algunos contenedores pueden tener muy pocos eventos y no eventos.\n", 87 | "2. El valor de la información no es un método de selección de características óptimas (variables) cuando se está construyendo un modelo de clasificación que no sea la regresión logística binaria (por ejemplo, bosque aleatorio o SVM), ya que las probabilidades de registro condicional (que predecimos en un modelo de regresión logística) están altamente relacionadas con el cálculo del peso de la evidencia. En otras palabras, está diseñado principalmente para el modelo de regresión logística binaria. También piense de esta manera: el bosque aleatorio puede detectar muy bien la relación no lineal, por lo que seleccionar variables a través de Information Value y usarlas en el modelo de bosque aleatorio podría no producir el modelo predictivo más preciso y robusto." 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 1, 93 | "id": "7320dc1a-c1ad-4884-9f52-02ad5d1ef74d", 94 | "metadata": {}, 95 | "outputs": [], 96 | "source": [ 97 | "import pandas as pd\n", 98 | "import numpy as np" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 3, 104 | "id": "a22647b8-0bfc-4288-b4c3-36987d470fca", 105 | "metadata": {}, 106 | "outputs": [ 107 | { 108 | "data": { 109 | "text/html": [ 110 | "
\n", 111 | "\n", 124 | "\n", 125 | " \n", 126 | " \n", 127 | " \n", 128 | " \n", 129 | " \n", 130 | " \n", 131 | " \n", 132 | " \n", 133 | " \n", 134 | " \n", 135 | " \n", 136 | " \n", 137 | " \n", 138 | " \n", 139 | " \n", 140 | " \n", 141 | " \n", 142 | " \n", 143 | " \n", 144 | " \n", 145 | " \n", 146 | " \n", 147 | " \n", 148 | " \n", 149 | " \n", 150 | " \n", 151 | " \n", 152 | " \n", 153 | " \n", 154 | " \n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | "
agejobmaritaleducationdefaultbalancehousingloancontactdaymonthdurationcampaignpdayspreviouspoutcomey
030unemployedmarriedprimaryno1787nonocellular19oct791-10unknownno
133servicesmarriedsecondaryno4789yesyescellular11may22013394failureno
235managementsingletertiaryno1350yesnocellular16apr18513301failureno
330managementmarriedtertiaryno1476yesyesunknown3jun1994-10unknownno
459blue-collarmarriedsecondaryno0yesnounknown5may2261-10unknownno
\n", 250 | "
" 251 | ], 252 | "text/plain": [ 253 | " age job marital education default balance housing loan \\\n", 254 | "0 30 unemployed married primary no 1787 no no \n", 255 | "1 33 services married secondary no 4789 yes yes \n", 256 | "2 35 management single tertiary no 1350 yes no \n", 257 | "3 30 management married tertiary no 1476 yes yes \n", 258 | "4 59 blue-collar married secondary no 0 yes no \n", 259 | "\n", 260 | " contact day month duration campaign pdays previous poutcome y \n", 261 | "0 cellular 19 oct 79 1 -1 0 unknown no \n", 262 | "1 cellular 11 may 220 1 339 4 failure no \n", 263 | "2 cellular 16 apr 185 1 330 1 failure no \n", 264 | "3 unknown 3 jun 199 4 -1 0 unknown no \n", 265 | "4 unknown 5 may 226 1 -1 0 unknown no " 266 | ] 267 | }, 268 | "execution_count": 3, 269 | "metadata": {}, 270 | "output_type": "execute_result" 271 | } 272 | ], 273 | "source": [ 274 | "df = pd.read_csv('bank.csv', sep=\";\")\n", 275 | "df.head()" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": null, 281 | "id": "12c34f69-825e-4876-8ffa-2c4064744c1f", 282 | "metadata": {}, 283 | "outputs": [], 284 | "source": [ 285 | "df.info()" 286 | ] 287 | }, 288 | { 289 | "cell_type": "markdown", 290 | "id": "d0de8e38-85ba-4afc-b53a-de3fb75337fc", 291 | "metadata": {}, 292 | "source": [ 293 | "Cambié la variable 'y' a numérica y la nombré como 'objetivo'. Como se mencionó anteriormente, el binning monotónico asegura que se establezca una relación lineal entre la variable independiente y dependiente. En el código, tengo dos funciones `mono_bin()` y `char_bin()`. La función mono_bin se utiliza para variables numéricas y char_bin se utiliza para variables de caracteres. Utilicé la correlación spearman para realizar el binning monótono." 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": 4, 299 | "id": "cb6241ad-0a52-4885-8c27-bd4b605db163", 300 | "metadata": {}, 301 | "outputs": [ 302 | { 303 | "data": { 304 | "text/plain": [ 305 | "no 4000\n", 306 | "yes 521\n", 307 | "Name: y, dtype: int64" 308 | ] 309 | }, 310 | "execution_count": 4, 311 | "metadata": {}, 312 | "output_type": "execute_result" 313 | } 314 | ], 315 | "source": [ 316 | "df['y'].value_counts()" 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": 5, 322 | "id": "3b2add4b-20db-4dd7-a20f-9c5915d0bed9", 323 | "metadata": {}, 324 | "outputs": [], 325 | "source": [ 326 | "df['target'] = df['y'].apply(lambda x : 1 if x == 'yes' else 0) # Convert to numeric\n", 327 | "df = df.drop('y',axis=1)" 328 | ] 329 | }, 330 | { 331 | "cell_type": "markdown", 332 | "id": "d955ebdb-f4af-493b-8eb2-b21600578f90", 333 | "metadata": {}, 334 | "source": [ 335 | "La variable 'max_bin' se utiliza para proporcionar el número máximo de contenedores (categorías) para el binning de variables numéricas. Para algunas variables numéricas, la función mono_bin produce solo una categoría mientras se agrupa. Para evitar eso, tengo otra variable llamada 'force_bin' para asegurarme de que al menos produzca 2 categorías." 336 | ] 337 | }, 338 | { 339 | "cell_type": "markdown", 340 | "id": "e40b4211-71fa-4199-af29-988ba7f881e1", 341 | "metadata": {}, 342 | "source": [ 343 | "El cálculo WOE y IV se puede invocar utilizando el siguiente código." 344 | ] 345 | }, 346 | { 347 | "cell_type": "code", 348 | "execution_count": 6, 349 | "id": "c129d2f0-66d5-42d1-a660-4387ad583256", 350 | "metadata": {}, 351 | "outputs": [], 352 | "source": [ 353 | "# import packages\n", 354 | "import pandas as pd\n", 355 | "import numpy as np\n", 356 | "import pandas.core.algorithms as algos\n", 357 | "from pandas import Series\n", 358 | "import scipy.stats.stats as stats\n", 359 | "import re\n", 360 | "import traceback\n", 361 | "import string\n", 362 | "\n", 363 | "max_bin = 20\n", 364 | "force_bin = 3" 365 | ] 366 | }, 367 | { 368 | "cell_type": "code", 369 | "execution_count": 7, 370 | "id": "24ecdd50-1ad6-4c43-99cb-50458dd444dd", 371 | "metadata": {}, 372 | "outputs": [], 373 | "source": [ 374 | "# define a binning function\n", 375 | "def mono_bin(Y, X, n = max_bin):\n", 376 | " \n", 377 | " df1 = pd.DataFrame({\"X\": X, \"Y\": Y})\n", 378 | " justmiss = df1[['X','Y']][df1.X.isnull()]\n", 379 | " notmiss = df1[['X','Y']][df1.X.notnull()]\n", 380 | " r = 0\n", 381 | " while np.abs(r) < 1:\n", 382 | " try:\n", 383 | " d1 = pd.DataFrame({\"X\": notmiss.X, \"Y\": notmiss.Y, \"Bucket\": pd.qcut(notmiss.X, n)})\n", 384 | " d2 = d1.groupby('Bucket', as_index=True)\n", 385 | " r, p = stats.spearmanr(d2.mean().X, d2.mean().Y)\n", 386 | " n = n - 1 \n", 387 | " except Exception as e:\n", 388 | " n = n - 1\n", 389 | "\n", 390 | " if len(d2) == 1:\n", 391 | " n = force_bin \n", 392 | " bins = algos.quantile(notmiss.X, np.linspace(0, 1, n))\n", 393 | " if len(np.unique(bins)) == 2:\n", 394 | " bins = np.insert(bins, 0, 1)\n", 395 | " bins[1] = bins[1]-(bins[1]/2)\n", 396 | " d1 = pd.DataFrame({\"X\": notmiss.X, \"Y\": notmiss.Y, \"Bucket\": pd.cut(notmiss.X, np.unique(bins),include_lowest=True)}) \n", 397 | " d2 = d1.groupby('Bucket', as_index=True)\n", 398 | " \n", 399 | " d3 = pd.DataFrame({},index=[])\n", 400 | " d3[\"MIN_VALUE\"] = d2.min().X\n", 401 | " d3[\"MAX_VALUE\"] = d2.max().X\n", 402 | " d3[\"COUNT\"] = d2.count().Y\n", 403 | " d3[\"EVENT\"] = d2.sum().Y\n", 404 | " d3[\"NONEVENT\"] = d2.count().Y - d2.sum().Y\n", 405 | " d3=d3.reset_index(drop=True)\n", 406 | " \n", 407 | " if len(justmiss.index) > 0:\n", 408 | " d4 = pd.DataFrame({'MIN_VALUE':np.nan},index=[0])\n", 409 | " d4[\"MAX_VALUE\"] = np.nan\n", 410 | " d4[\"COUNT\"] = justmiss.count().Y\n", 411 | " d4[\"EVENT\"] = justmiss.sum().Y\n", 412 | " d4[\"NONEVENT\"] = justmiss.count().Y - justmiss.sum().Y\n", 413 | " d3 = d3.append(d4,ignore_index=True)\n", 414 | " \n", 415 | " d3[\"EVENT_RATE\"] = d3.EVENT/d3.COUNT\n", 416 | " d3[\"NON_EVENT_RATE\"] = d3.NONEVENT/d3.COUNT\n", 417 | " d3[\"DIST_EVENT\"] = d3.EVENT/d3.sum().EVENT\n", 418 | " d3[\"DIST_NON_EVENT\"] = d3.NONEVENT/d3.sum().NONEVENT\n", 419 | " d3[\"WOE\"] = np.log(d3.DIST_EVENT/d3.DIST_NON_EVENT)\n", 420 | " d3[\"IV\"] = (d3.DIST_EVENT-d3.DIST_NON_EVENT)*np.log(d3.DIST_EVENT/d3.DIST_NON_EVENT)\n", 421 | " d3[\"VAR_NAME\"] = \"VAR\"\n", 422 | " d3 = d3[['VAR_NAME','MIN_VALUE', 'MAX_VALUE', 'COUNT', 'EVENT', 'EVENT_RATE', 'NONEVENT', 'NON_EVENT_RATE', 'DIST_EVENT','DIST_NON_EVENT','WOE', 'IV']] \n", 423 | " d3 = d3.replace([np.inf, -np.inf], 0)\n", 424 | " d3.IV = d3.IV.sum()\n", 425 | " \n", 426 | " return(d3)" 427 | ] 428 | }, 429 | { 430 | "cell_type": "code", 431 | "execution_count": 8, 432 | "id": "e0de934b-4d11-4c21-b7cc-6c65cbd20694", 433 | "metadata": {}, 434 | "outputs": [], 435 | "source": [ 436 | "def char_bin(Y, X):\n", 437 | " \n", 438 | " df1 = pd.DataFrame({\"X\": X, \"Y\": Y})\n", 439 | " justmiss = df1[['X','Y']][df1.X.isnull()]\n", 440 | " notmiss = df1[['X','Y']][df1.X.notnull()] \n", 441 | " df2 = notmiss.groupby('X',as_index=True)\n", 442 | " \n", 443 | " d3 = pd.DataFrame({},index=[])\n", 444 | " d3[\"COUNT\"] = df2.count().Y\n", 445 | " d3[\"MIN_VALUE\"] = df2.sum().Y.index\n", 446 | " d3[\"MAX_VALUE\"] = d3[\"MIN_VALUE\"]\n", 447 | " d3[\"EVENT\"] = df2.sum().Y\n", 448 | " d3[\"NONEVENT\"] = df2.count().Y - df2.sum().Y\n", 449 | " \n", 450 | " if len(justmiss.index) > 0:\n", 451 | " d4 = pd.DataFrame({'MIN_VALUE':np.nan},index=[0])\n", 452 | " d4[\"MAX_VALUE\"] = np.nan\n", 453 | " d4[\"COUNT\"] = justmiss.count().Y\n", 454 | " d4[\"EVENT\"] = justmiss.sum().Y\n", 455 | " d4[\"NONEVENT\"] = justmiss.count().Y - justmiss.sum().Y\n", 456 | " d3 = d3.append(d4,ignore_index=True)\n", 457 | " \n", 458 | " d3[\"EVENT_RATE\"] = d3.EVENT/d3.COUNT\n", 459 | " d3[\"NON_EVENT_RATE\"] = d3.NONEVENT/d3.COUNT\n", 460 | " d3[\"DIST_EVENT\"] = d3.EVENT/d3.sum().EVENT\n", 461 | " d3[\"DIST_NON_EVENT\"] = d3.NONEVENT/d3.sum().NONEVENT\n", 462 | " d3[\"WOE\"] = np.log(d3.DIST_EVENT/d3.DIST_NON_EVENT)\n", 463 | " d3[\"IV\"] = (d3.DIST_EVENT-d3.DIST_NON_EVENT)*np.log(d3.DIST_EVENT/d3.DIST_NON_EVENT)\n", 464 | " d3[\"VAR_NAME\"] = \"VAR\"\n", 465 | " d3 = d3[['VAR_NAME','MIN_VALUE', 'MAX_VALUE', 'COUNT', 'EVENT', 'EVENT_RATE', 'NONEVENT', 'NON_EVENT_RATE', 'DIST_EVENT','DIST_NON_EVENT','WOE', 'IV']] \n", 466 | " d3 = d3.replace([np.inf, -np.inf], 0)\n", 467 | " d3.IV = d3.IV.sum()\n", 468 | " d3 = d3.reset_index(drop=True)\n", 469 | " \n", 470 | " return(d3)" 471 | ] 472 | }, 473 | { 474 | "cell_type": "code", 475 | "execution_count": 9, 476 | "id": "84ee2600-c2af-4f13-befe-aeaf6c37d8d3", 477 | "metadata": {}, 478 | "outputs": [], 479 | "source": [ 480 | "def data_vars(df1, target):\n", 481 | " \n", 482 | " stack = traceback.extract_stack()\n", 483 | " filename, lineno, function_name, code = stack[-2]\n", 484 | " vars_name = re.compile(r'\\((.*?)\\).*$').search(code).groups()[0]\n", 485 | " final = (re.findall(r\"[\\w']+\", vars_name))[-1]\n", 486 | " \n", 487 | " x = df1.dtypes.index\n", 488 | " count = -1\n", 489 | " \n", 490 | " for i in x:\n", 491 | " if i.upper() not in (final.upper()):\n", 492 | " if np.issubdtype(df1[i], np.number) and len(Series.unique(df1[i])) > 2:\n", 493 | " conv = mono_bin(target, df1[i])\n", 494 | " conv[\"VAR_NAME\"] = i\n", 495 | " count = count + 1\n", 496 | " else:\n", 497 | " conv = char_bin(target, df1[i])\n", 498 | " conv[\"VAR_NAME\"] = i \n", 499 | " count = count + 1\n", 500 | " \n", 501 | " if count == 0:\n", 502 | " iv_df = conv\n", 503 | " else:\n", 504 | " iv_df = iv_df.append(conv,ignore_index=True)\n", 505 | " \n", 506 | " iv = pd.DataFrame({'IV':iv_df.groupby('VAR_NAME').IV.max()})\n", 507 | " iv = iv.reset_index()\n", 508 | " return(iv_df,iv) " 509 | ] 510 | }, 511 | { 512 | "cell_type": "code", 513 | "execution_count": 10, 514 | "id": "8bdbff32-d682-440e-a710-6c2f12dce163", 515 | "metadata": {}, 516 | "outputs": [], 517 | "source": [ 518 | "final_iv, IV = data_vars(df,df.target)" 519 | ] 520 | }, 521 | { 522 | "cell_type": "code", 523 | "execution_count": 12, 524 | "id": "98e11387-4b66-4caf-b88e-b65e42d682d1", 525 | "metadata": {}, 526 | "outputs": [ 527 | { 528 | "data": { 529 | "text/html": [ 530 | "
\n", 531 | "\n", 544 | "\n", 545 | " \n", 546 | " \n", 547 | " \n", 548 | " \n", 549 | " \n", 550 | " \n", 551 | " \n", 552 | " \n", 553 | " \n", 554 | " \n", 555 | " \n", 556 | " \n", 557 | " \n", 558 | " \n", 559 | " \n", 560 | " \n", 561 | " \n", 562 | " \n", 563 | " \n", 564 | " \n", 565 | " \n", 566 | " \n", 567 | " \n", 568 | " \n", 569 | " \n", 570 | " \n", 571 | " \n", 572 | " \n", 573 | " \n", 574 | " \n", 575 | " \n", 576 | " \n", 577 | " \n", 578 | " \n", 579 | " \n", 580 | " \n", 581 | " \n", 582 | " \n", 583 | " \n", 584 | " \n", 585 | " \n", 586 | " \n", 587 | " \n", 588 | " \n", 589 | " \n", 590 | " \n", 591 | " \n", 592 | " \n", 593 | " \n", 594 | " \n", 595 | " \n", 596 | " \n", 597 | " \n", 598 | " \n", 599 | " \n", 600 | " \n", 601 | " \n", 602 | " \n", 603 | " \n", 604 | " \n", 605 | " \n", 606 | " \n", 607 | " \n", 608 | " \n", 609 | " \n", 610 | " \n", 611 | " \n", 612 | " \n", 613 | " \n", 614 | " \n", 615 | " \n", 616 | " \n", 617 | " \n", 618 | " \n", 619 | " \n", 620 | " \n", 621 | " \n", 622 | " \n", 623 | " \n", 624 | " \n", 625 | " \n", 626 | " \n", 627 | " \n", 628 | " \n", 629 | " \n", 630 | " \n", 631 | " \n", 632 | " \n", 633 | " \n", 634 | " \n", 635 | " \n", 636 | " \n", 637 | " \n", 638 | " \n", 639 | "
VAR_NAMEMIN_VALUEMAX_VALUECOUNTEVENTEVENT_RATENONEVENTNON_EVENT_RATEDIST_EVENTDIST_NON_EVENTWOEIV
0age193922902590.11310020310.8869000.4971210.50775-0.0211560.000452
1age408722312620.11743619690.8825640.5028790.492250.0213630.000452
2jobadmin.admin.478580.1213394200.8786610.1113240.105000.0584880.132519
3jobblue-collarblue-collar946690.0729398770.9270610.1324380.21925-0.5041010.132519
4jobentrepreneurentrepreneur168150.0892861530.9107140.0287910.03825-0.2840880.132519
\n", 640 | "
" 641 | ], 642 | "text/plain": [ 643 | " VAR_NAME MIN_VALUE MAX_VALUE COUNT EVENT EVENT_RATE NONEVENT \\\n", 644 | "0 age 19 39 2290 259 0.113100 2031 \n", 645 | "1 age 40 87 2231 262 0.117436 1969 \n", 646 | "2 job admin. admin. 478 58 0.121339 420 \n", 647 | "3 job blue-collar blue-collar 946 69 0.072939 877 \n", 648 | "4 job entrepreneur entrepreneur 168 15 0.089286 153 \n", 649 | "\n", 650 | " NON_EVENT_RATE DIST_EVENT DIST_NON_EVENT WOE IV \n", 651 | "0 0.886900 0.497121 0.50775 -0.021156 0.000452 \n", 652 | "1 0.882564 0.502879 0.49225 0.021363 0.000452 \n", 653 | "2 0.878661 0.111324 0.10500 0.058488 0.132519 \n", 654 | "3 0.927061 0.132438 0.21925 -0.504101 0.132519 \n", 655 | "4 0.910714 0.028791 0.03825 -0.284088 0.132519 " 656 | ] 657 | }, 658 | "execution_count": 12, 659 | "metadata": {}, 660 | "output_type": "execute_result" 661 | } 662 | ], 663 | "source": [ 664 | "final_iv.head()" 665 | ] 666 | }, 667 | { 668 | "cell_type": "markdown", 669 | "id": "88961c2b-6137-498c-af7d-23dd936be9c0", 670 | "metadata": {}, 671 | "source": [ 672 | "Sobre la base de la información anterior, las variables se pueden seleccionar en función de su poder predictivo." 673 | ] 674 | }, 675 | { 676 | "cell_type": "markdown", 677 | "id": "c4b5fd95-89ca-4fc5-b53c-593e405aad3f", 678 | "metadata": {}, 679 | "source": [ 680 | "|Poder de la Predicción|Nombre de la variable|\n", 681 | "|----------------------|---------------------|\n", 682 | "|inútil para la predicción|default, age|\n", 683 | "|predictor débil|campaing, day, education,marital, loan, balance|\n", 684 | "|predictor medio|housing, job, previous,pdays, contact|\n", 685 | "|predictor fuerte|month, poutcome|\n", 686 | "|Sospechoso o demasiado bueno para ser verdad|duration|\n" 687 | ] 688 | }, 689 | { 690 | "cell_type": "code", 691 | "execution_count": 13, 692 | "id": "6f007443-9e5a-4179-8bc0-3d407c5072ad", 693 | "metadata": {}, 694 | "outputs": [ 695 | { 696 | "data": { 697 | "text/html": [ 698 | "
\n", 699 | "\n", 712 | "\n", 713 | " \n", 714 | " \n", 715 | " \n", 716 | " \n", 717 | " \n", 718 | " \n", 719 | " \n", 720 | " \n", 721 | " \n", 722 | " \n", 723 | " \n", 724 | " \n", 725 | " \n", 726 | " \n", 727 | " \n", 728 | " \n", 729 | " \n", 730 | " \n", 731 | " \n", 732 | " \n", 733 | " \n", 734 | " \n", 735 | " \n", 736 | " \n", 737 | " \n", 738 | " \n", 739 | " \n", 740 | " \n", 741 | " \n", 742 | " \n", 743 | " \n", 744 | " \n", 745 | " \n", 746 | " \n", 747 | " \n", 748 | " \n", 749 | " \n", 750 | " \n", 751 | " \n", 752 | " \n", 753 | " \n", 754 | " \n", 755 | " \n", 756 | " \n", 757 | " \n", 758 | " \n", 759 | " \n", 760 | " \n", 761 | " \n", 762 | " \n", 763 | " \n", 764 | " \n", 765 | " \n", 766 | " \n", 767 | " \n", 768 | " \n", 769 | " \n", 770 | " \n", 771 | " \n", 772 | " \n", 773 | " \n", 774 | " \n", 775 | " \n", 776 | " \n", 777 | " \n", 778 | " \n", 779 | " \n", 780 | " \n", 781 | " \n", 782 | " \n", 783 | " \n", 784 | " \n", 785 | " \n", 786 | " \n", 787 | " \n", 788 | " \n", 789 | " \n", 790 | " \n", 791 | " \n", 792 | " \n", 793 | " \n", 794 | " \n", 795 | " \n", 796 | " \n", 797 | " \n", 798 | " \n", 799 | " \n", 800 | " \n", 801 | " \n", 802 | "
VAR_NAMEIV
5default0.000016
0age0.000452
4day0.004581
2campaign0.023342
7education0.031812
11marital0.040090
10loan0.060791
1balance0.076208
8housing0.106556
9job0.132519
15previous0.177081
13pdays0.203267
3contact0.247762
12month0.379533
14poutcome0.461890
6duration1.651501
\n", 803 | "
" 804 | ], 805 | "text/plain": [ 806 | " VAR_NAME IV\n", 807 | "5 default 0.000016\n", 808 | "0 age 0.000452\n", 809 | "4 day 0.004581\n", 810 | "2 campaign 0.023342\n", 811 | "7 education 0.031812\n", 812 | "11 marital 0.040090\n", 813 | "10 loan 0.060791\n", 814 | "1 balance 0.076208\n", 815 | "8 housing 0.106556\n", 816 | "9 job 0.132519\n", 817 | "15 previous 0.177081\n", 818 | "13 pdays 0.203267\n", 819 | "3 contact 0.247762\n", 820 | "12 month 0.379533\n", 821 | "14 poutcome 0.461890\n", 822 | "6 duration 1.651501" 823 | ] 824 | }, 825 | "execution_count": 13, 826 | "metadata": {}, 827 | "output_type": "execute_result" 828 | } 829 | ], 830 | "source": [ 831 | "IV.sort_values('IV')" 832 | ] 833 | }, 834 | { 835 | "cell_type": "markdown", 836 | "id": "8d773cdf-cf2e-40d1-8700-0d5647ed9329", 837 | "metadata": {}, 838 | "source": [ 839 | "### Aplicar valores WOE a las columnas de nuestro DataFrame.\n", 840 | "\n", 841 | "El siguiente código se puede usar para aplicar los valores de WOE a las columnas de nuestro DataFrame." 842 | ] 843 | }, 844 | { 845 | "cell_type": "code", 846 | "execution_count": 14, 847 | "id": "627943b5-8846-43fd-8d65-9cd52bc2e9d7", 848 | "metadata": {}, 849 | "outputs": [], 850 | "source": [ 851 | "transform_vars_list = df.columns.difference(['target'])\n", 852 | "transform_prefix = 'new_' # deje este valor en blanco si necesita reemplazar los valores de columna originales" 853 | ] 854 | }, 855 | { 856 | "cell_type": "code", 857 | "execution_count": 15, 858 | "id": "f7a0ebe4-009b-47d1-b791-9ac72ef4e358", 859 | "metadata": {}, 860 | "outputs": [ 861 | { 862 | "data": { 863 | "text/plain": [ 864 | "Index(['age', 'balance', 'campaign', 'contact', 'day', 'default', 'duration',\n", 865 | " 'education', 'housing', 'job', 'loan', 'marital', 'month', 'pdays',\n", 866 | " 'poutcome', 'previous'],\n", 867 | " dtype='object')" 868 | ] 869 | }, 870 | "execution_count": 15, 871 | "metadata": {}, 872 | "output_type": "execute_result" 873 | } 874 | ], 875 | "source": [ 876 | "transform_vars_list" 877 | ] 878 | }, 879 | { 880 | "cell_type": "code", 881 | "execution_count": 17, 882 | "id": "93e25750-38ce-4ad8-95c1-b01e81c57313", 883 | "metadata": {}, 884 | "outputs": [], 885 | "source": [ 886 | "for var in transform_vars_list:\n", 887 | " small_df = final_iv[final_iv['VAR_NAME'] == var]\n", 888 | " transform_dict = dict(zip(small_df.MAX_VALUE,small_df.WOE))\n", 889 | " replace_cmd = ''\n", 890 | " replace_cmd1 = ''\n", 891 | " for i in sorted(transform_dict.items()):\n", 892 | " replace_cmd = replace_cmd + str(i[1]) + str(' if x <= ') + str(i[0]) + ' else '\n", 893 | " replace_cmd1 = replace_cmd1 + str(i[1]) + str(' if x == \"') + str(i[0]) + '\" else '\n", 894 | " replace_cmd = replace_cmd + '0'\n", 895 | " replace_cmd1 = replace_cmd1 + '0'\n", 896 | " if replace_cmd != '0':\n", 897 | " try:\n", 898 | " df[transform_prefix + var] = df[var].apply(lambda x: eval(replace_cmd))\n", 899 | " except:\n", 900 | " df[transform_prefix + var] = df[var].apply(lambda x: eval(replace_cmd1))" 901 | ] 902 | }, 903 | { 904 | "cell_type": "code", 905 | "execution_count": 18, 906 | "id": "b72cc3bb-6024-4656-8b7e-c574769fedbf", 907 | "metadata": {}, 908 | "outputs": [ 909 | { 910 | "data": { 911 | "text/plain": [ 912 | "cellular 2896\n", 913 | "unknown 1324\n", 914 | "telephone 301\n", 915 | "Name: contact, dtype: int64" 916 | ] 917 | }, 918 | "execution_count": 18, 919 | "metadata": {}, 920 | "output_type": "execute_result" 921 | } 922 | ], 923 | "source": [ 924 | "df['contact'].value_counts()" 925 | ] 926 | }, 927 | { 928 | "cell_type": "code", 929 | "execution_count": 19, 930 | "id": "00d3666f-ba78-4c40-8521-60b08b21132d", 931 | "metadata": {}, 932 | "outputs": [ 933 | { 934 | "data": { 935 | "text/plain": [ 936 | " 0.252971 2896\n", 937 | "-0.992072 1324\n", 938 | " 0.273413 301\n", 939 | "Name: new_contact, dtype: int64" 940 | ] 941 | }, 942 | "execution_count": 19, 943 | "metadata": {}, 944 | "output_type": "execute_result" 945 | } 946 | ], 947 | "source": [ 948 | "df['new_contact'].value_counts()" 949 | ] 950 | }, 951 | { 952 | "cell_type": "code", 953 | "execution_count": 20, 954 | "id": "6e9b7c7b-cc1a-411d-bce0-a32fad2e26c7", 955 | "metadata": {}, 956 | "outputs": [], 957 | "source": [ 958 | "small_df = final_iv[final_iv['VAR_NAME'] == 'contact']" 959 | ] 960 | }, 961 | { 962 | "cell_type": "code", 963 | "execution_count": 21, 964 | "id": "2cec234b-71ce-4053-8fc1-08b11f1cc99e", 965 | "metadata": {}, 966 | "outputs": [ 967 | { 968 | "data": { 969 | "text/html": [ 970 | "
\n", 971 | "\n", 984 | "\n", 985 | " \n", 986 | " \n", 987 | " \n", 988 | " \n", 989 | " \n", 990 | " \n", 991 | " \n", 992 | " \n", 993 | " \n", 994 | " \n", 995 | " \n", 996 | " \n", 997 | " \n", 998 | " \n", 999 | " \n", 1000 | " \n", 1001 | " \n", 1002 | " \n", 1003 | " \n", 1004 | " \n", 1005 | " \n", 1006 | " \n", 1007 | " \n", 1008 | " \n", 1009 | " \n", 1010 | " \n", 1011 | " \n", 1012 | " \n", 1013 | " \n", 1014 | " \n", 1015 | " \n", 1016 | " \n", 1017 | " \n", 1018 | " \n", 1019 | " \n", 1020 | " \n", 1021 | " \n", 1022 | " \n", 1023 | " \n", 1024 | " \n", 1025 | " \n", 1026 | " \n", 1027 | " \n", 1028 | " \n", 1029 | " \n", 1030 | " \n", 1031 | " \n", 1032 | " \n", 1033 | " \n", 1034 | " \n", 1035 | " \n", 1036 | " \n", 1037 | " \n", 1038 | " \n", 1039 | " \n", 1040 | " \n", 1041 | " \n", 1042 | " \n", 1043 | " \n", 1044 | " \n", 1045 | " \n", 1046 | " \n", 1047 | " \n", 1048 | " \n", 1049 | "
VAR_NAMEMIN_VALUEMAX_VALUECOUNTEVENTEVENT_RATENONEVENTNON_EVENT_RATEDIST_EVENTDIST_NON_EVENTWOEIV
31contactcellularcellular28964160.14364624800.8563540.7984640.620000.2529710.247762
32contacttelephonetelephone301440.1461792570.8538210.0844530.064250.2734130.247762
33contactunknownunknown1324610.04607312630.9539270.1170830.31575-0.9920720.247762
\n", 1050 | "
" 1051 | ], 1052 | "text/plain": [ 1053 | " VAR_NAME MIN_VALUE MAX_VALUE COUNT EVENT EVENT_RATE NONEVENT \\\n", 1054 | "31 contact cellular cellular 2896 416 0.143646 2480 \n", 1055 | "32 contact telephone telephone 301 44 0.146179 257 \n", 1056 | "33 contact unknown unknown 1324 61 0.046073 1263 \n", 1057 | "\n", 1058 | " NON_EVENT_RATE DIST_EVENT DIST_NON_EVENT WOE IV \n", 1059 | "31 0.856354 0.798464 0.62000 0.252971 0.247762 \n", 1060 | "32 0.853821 0.084453 0.06425 0.273413 0.247762 \n", 1061 | "33 0.953927 0.117083 0.31575 -0.992072 0.247762 " 1062 | ] 1063 | }, 1064 | "execution_count": 21, 1065 | "metadata": {}, 1066 | "output_type": "execute_result" 1067 | } 1068 | ], 1069 | "source": [ 1070 | "small_df" 1071 | ] 1072 | } 1073 | ], 1074 | "metadata": { 1075 | "kernelspec": { 1076 | "display_name": "Python 3 (ipykernel)", 1077 | "language": "python", 1078 | "name": "python3" 1079 | }, 1080 | "language_info": { 1081 | "codemirror_mode": { 1082 | "name": "ipython", 1083 | "version": 3 1084 | }, 1085 | "file_extension": ".py", 1086 | "mimetype": "text/x-python", 1087 | "name": "python", 1088 | "nbconvert_exporter": "python", 1089 | "pygments_lexer": "ipython3", 1090 | "version": "3.9.9" 1091 | } 1092 | }, 1093 | "nbformat": 4, 1094 | "nbformat_minor": 5 1095 | } 1096 | -------------------------------------------------------------------------------- /Convertir variables categóricas en numéricas.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Untitled0.ipynb", 7 | "provenance": [], 8 | "mount_file_id": "1TejJmrxq59-K6F4ReIXqc55FhWvA-eE8", 9 | "authorship_tag": "ABX9TyPi/65+82QHibpVsshpw8ew", 10 | "include_colab_link": true 11 | }, 12 | "kernelspec": { 13 | "name": "python3", 14 | "display_name": "Python 3" 15 | } 16 | }, 17 | "cells": [ 18 | { 19 | "cell_type": "markdown", 20 | "metadata": { 21 | "id": "view-in-github", 22 | "colab_type": "text" 23 | }, 24 | "source": [ 25 | "\"Open" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "metadata": { 31 | "id": "n12NSTFRn-Hp" 32 | }, 33 | "source": [ 34 | "# **Convertir variables categoricas en numéricas**" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "metadata": { 40 | "colab": { 41 | "base_uri": "https://localhost:8080/", 42 | "height": 297 43 | }, 44 | "cellView": "form", 45 | "id": "TiTQOt6et5MH", 46 | "outputId": "f1da23c7-74c5-4b75-b5b3-06afa314dc35" 47 | }, 48 | "source": [ 49 | "#@title **Método One-Hot**\r\n", 50 | "from IPython.display import Image\r\n", 51 | "Image(\"/content/drive/MyDrive/imagenes/one_hot.png\")" 52 | ], 53 | "execution_count": 2, 54 | "outputs": [ 55 | { 56 | "output_type": "execute_result", 57 | "data": { 58 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAsoAAAEYCAYAAABFiND5AAA0K0lEQVR42u2dDaxd1ZXfr8YevsqHqcvXmIkJzJg4cWuEp1A8yBQGEAESN6ZkcEMGCMNAQA4FxSOoExIoSE7jpKZYgTI8v6RWsSBDAgKFAFGIjIzkThgFIYSoGnUiFSVqgho1UZOZtHPK74j9tN72Offr3ffeOff+lvTXe++c+/XuOmet31l77X06HU3TNE3TNE3TNE3TNE3TNE3TNE3TNE3TNE3TNE3TNE3TNE3TNE3TNE3TFtemp6dv9VvQNM9NTV9r+lHTj/ows927d7/9jv67UqpZmpqa+s07usKQN/5mHB6fc9bvQT+qZvhwZLDMC27Z/dNCKdUs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JypqmaZqgLGAp/agEZU3TNE1QFrCUflSCsqZpmiYoC1hKPypBWdM0TROUlYClH5WgrGmapgnKSsDSj0pQ1jRN0wRlJWDpRyUoa5qmaYKyErCUfhSUNU3TNEFZCVhKPwrKmqZpmqCsBCylHwXlevv/0tPcAFlDM98AAAAASUVORK5CYII=\n", 59 | "text/plain": [ 60 | "" 61 | ] 62 | }, 63 | "metadata": { 64 | "tags": [] 65 | }, 66 | "execution_count": 2 67 | } 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "metadata": { 73 | "id": "stVqWG8jsqNB" 74 | }, 75 | "source": [ 76 | "**¿Qué es One Hot Encoding?**\r\n", 77 | "\r\n", 78 | "Una codificación one hot es una representación de variables categóricas como vectores binarios.\r\n", 79 | "\r\n", 80 | "Esto primero requiere que los valores categóricos se asignen a valores enteros.\r\n", 81 | "\r\n", 82 | "Luego, cada valor entero se representa como un vector binario que tiene todos los valores cero excepto el índice del entero, que está marcado con un 1." 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": { 88 | "id": "n_XSHTIUs6ZC" 89 | }, 90 | "source": [ 91 | "**¿Por qué utilizar una codificación One Hot?**\r\n", 92 | "\r\n", 93 | "Una codificación one hot permite que la representación de datos categóricos sea más expresiva.\r\n", 94 | "\r\n", 95 | "Muchos algoritmos de aprendizaje automático no pueden trabajar directamente con datos categóricos. Las categorías deben convertirse en números. Esto es necesario para las variables de entrada y salida que son categóricas." 96 | ] 97 | }, 98 | { 99 | "cell_type": "markdown", 100 | "metadata": { 101 | "id": "OHS9pvxXtVhh" 102 | }, 103 | "source": [ 104 | "En estos casos, nos gustaría darle a la red más poder expresivo para aprender un número similar a la probabilidad para cada posible valor de etiqueta. Esto puede ayudar a que el problema sea más fácil de modelar para la red. Cuando se usa una codificación en caliente para la variable de salida, puede ofrecer un conjunto de predicciones más matizado que una sola etiqueta." 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "metadata": { 110 | "id": "tgj4VAD6ooig" 111 | }, 112 | "source": [ 113 | "import pandas as pd\r\n", 114 | "import numpy as np\r\n", 115 | "import seaborn as sns" 116 | ], 117 | "execution_count": 4, 118 | "outputs": [] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "metadata": { 123 | "colab": { 124 | "base_uri": "https://localhost:8080/", 125 | "height": 359 126 | }, 127 | "id": "wHsvq7TZvxZF", 128 | "outputId": "0e49eaf1-2b8d-4d16-ec6b-ac8f5f95d27d" 129 | }, 130 | "source": [ 131 | "datos=sns.load_dataset(\"tips\")\r\n", 132 | "datos.head(10)" 133 | ], 134 | "execution_count": 6, 135 | "outputs": [ 136 | { 137 | "output_type": "execute_result", 138 | "data": { 139 | "text/html": [ 140 | "
\n", 141 | "\n", 154 | "\n", 155 | " \n", 156 | " \n", 157 | " \n", 158 | " \n", 159 | " \n", 160 | " \n", 161 | " \n", 162 | " \n", 163 | " \n", 164 | " \n", 165 | " \n", 166 | " \n", 167 | " \n", 168 | " \n", 169 | " \n", 170 | " \n", 171 | " \n", 172 | " \n", 173 | " \n", 174 | " \n", 175 | " \n", 176 | " \n", 177 | " \n", 178 | " \n", 179 | " \n", 180 | " \n", 181 | " \n", 182 | " \n", 183 | " \n", 184 | " \n", 185 | " \n", 186 | " \n", 187 | " \n", 188 | " \n", 189 | " \n", 190 | " \n", 191 | " \n", 192 | " \n", 193 | " \n", 194 | " \n", 195 | " \n", 196 | " \n", 197 | " \n", 198 | " \n", 199 | " \n", 200 | " \n", 201 | " \n", 202 | " \n", 203 | " \n", 204 | " \n", 205 | " \n", 206 | " \n", 207 | " \n", 208 | " \n", 209 | " \n", 210 | " \n", 211 | " \n", 212 | " \n", 213 | " \n", 214 | " \n", 215 | " \n", 216 | " \n", 217 | " \n", 218 | " \n", 219 | " \n", 220 | " \n", 221 | " \n", 222 | " \n", 223 | " \n", 224 | " \n", 225 | " \n", 226 | " \n", 227 | " \n", 228 | " \n", 229 | " \n", 230 | " \n", 231 | " \n", 232 | " \n", 233 | " \n", 234 | " \n", 235 | " \n", 236 | " \n", 237 | " \n", 238 | " \n", 239 | " \n", 240 | " \n", 241 | " \n", 242 | " \n", 243 | " \n", 244 | " \n", 245 | " \n", 246 | " \n", 247 | " \n", 248 | " \n", 249 | " \n", 250 | " \n", 251 | " \n", 252 | " \n", 253 | " \n", 254 | " \n", 255 | " \n", 256 | " \n", 257 | " \n", 258 | " \n", 259 | " \n", 260 | " \n", 261 | " \n", 262 | " \n", 263 | " \n", 264 | " \n", 265 | " \n", 266 | " \n", 267 | " \n", 268 | " \n", 269 | "
total_billtipsexsmokerdaytimesize
016.991.01FemaleNoSunDinner2
110.341.66MaleNoSunDinner3
221.013.50MaleNoSunDinner3
323.683.31MaleNoSunDinner2
424.593.61FemaleNoSunDinner4
525.294.71MaleNoSunDinner4
68.772.00MaleNoSunDinner2
726.883.12MaleNoSunDinner4
815.041.96MaleNoSunDinner2
914.783.23MaleNoSunDinner2
\n", 270 | "
" 271 | ], 272 | "text/plain": [ 273 | " total_bill tip sex smoker day time size\n", 274 | "0 16.99 1.01 Female No Sun Dinner 2\n", 275 | "1 10.34 1.66 Male No Sun Dinner 3\n", 276 | "2 21.01 3.50 Male No Sun Dinner 3\n", 277 | "3 23.68 3.31 Male No Sun Dinner 2\n", 278 | "4 24.59 3.61 Female No Sun Dinner 4\n", 279 | "5 25.29 4.71 Male No Sun Dinner 4\n", 280 | "6 8.77 2.00 Male No Sun Dinner 2\n", 281 | "7 26.88 3.12 Male No Sun Dinner 4\n", 282 | "8 15.04 1.96 Male No Sun Dinner 2\n", 283 | "9 14.78 3.23 Male No Sun Dinner 2" 284 | ] 285 | }, 286 | "metadata": { 287 | "tags": [] 288 | }, 289 | "execution_count": 6 290 | } 291 | ] 292 | }, 293 | { 294 | "cell_type": "code", 295 | "metadata": { 296 | "colab": { 297 | "base_uri": "https://localhost:8080/", 298 | "height": 359 299 | }, 300 | "id": "Ivu6QHe3wWx-", 301 | "outputId": "8e9a5903-c3c3-4f20-fafe-4d5d5b93a96a" 302 | }, 303 | "source": [ 304 | "numerica=datos.drop([\"sex\",\"smoker\", \"day\", \"time\"], axis=1)\r\n", 305 | "numerica.head(10)" 306 | ], 307 | "execution_count": 8, 308 | "outputs": [ 309 | { 310 | "output_type": "execute_result", 311 | "data": { 312 | "text/html": [ 313 | "
\n", 314 | "\n", 327 | "\n", 328 | " \n", 329 | " \n", 330 | " \n", 331 | " \n", 332 | " \n", 333 | " \n", 334 | " \n", 335 | " \n", 336 | " \n", 337 | " \n", 338 | " \n", 339 | " \n", 340 | " \n", 341 | " \n", 342 | " \n", 343 | " \n", 344 | " \n", 345 | " \n", 346 | " \n", 347 | " \n", 348 | " \n", 349 | " \n", 350 | " \n", 351 | " \n", 352 | " \n", 353 | " \n", 354 | " \n", 355 | " \n", 356 | " \n", 357 | " \n", 358 | " \n", 359 | " \n", 360 | " \n", 361 | " \n", 362 | " \n", 363 | " \n", 364 | " \n", 365 | " \n", 366 | " \n", 367 | " \n", 368 | " \n", 369 | " \n", 370 | " \n", 371 | " \n", 372 | " \n", 373 | " \n", 374 | " \n", 375 | " \n", 376 | " \n", 377 | " \n", 378 | " \n", 379 | " \n", 380 | " \n", 381 | " \n", 382 | " \n", 383 | " \n", 384 | " \n", 385 | " \n", 386 | " \n", 387 | " \n", 388 | " \n", 389 | " \n", 390 | " \n", 391 | " \n", 392 | " \n", 393 | " \n", 394 | " \n", 395 | " \n", 396 | " \n", 397 | " \n", 398 | "
total_billtipsize
016.991.012
110.341.663
221.013.503
323.683.312
424.593.614
525.294.714
68.772.002
726.883.124
815.041.962
914.783.232
\n", 399 | "
" 400 | ], 401 | "text/plain": [ 402 | " total_bill tip size\n", 403 | "0 16.99 1.01 2\n", 404 | "1 10.34 1.66 3\n", 405 | "2 21.01 3.50 3\n", 406 | "3 23.68 3.31 2\n", 407 | "4 24.59 3.61 4\n", 408 | "5 25.29 4.71 4\n", 409 | "6 8.77 2.00 2\n", 410 | "7 26.88 3.12 4\n", 411 | "8 15.04 1.96 2\n", 412 | "9 14.78 3.23 2" 413 | ] 414 | }, 415 | "metadata": { 416 | "tags": [] 417 | }, 418 | "execution_count": 8 419 | } 420 | ] 421 | }, 422 | { 423 | "cell_type": "code", 424 | "metadata": { 425 | "colab": { 426 | "base_uri": "https://localhost:8080/", 427 | "height": 359 428 | }, 429 | "id": "4X6KkpOYw9h1", 430 | "outputId": "b3c3e636-bd14-4512-be7f-cecd18a93435" 431 | }, 432 | "source": [ 433 | "categorica=datos.filter([\"sex\",\"smoker\", \"day\", \"time\"])\r\n", 434 | "categorica.head(10)" 435 | ], 436 | "execution_count": 10, 437 | "outputs": [ 438 | { 439 | "output_type": "execute_result", 440 | "data": { 441 | "text/html": [ 442 | "
\n", 443 | "\n", 456 | "\n", 457 | " \n", 458 | " \n", 459 | " \n", 460 | " \n", 461 | " \n", 462 | " \n", 463 | " \n", 464 | " \n", 465 | " \n", 466 | " \n", 467 | " \n", 468 | " \n", 469 | " \n", 470 | " \n", 471 | " \n", 472 | " \n", 473 | " \n", 474 | " \n", 475 | " \n", 476 | " \n", 477 | " \n", 478 | " \n", 479 | " \n", 480 | " \n", 481 | " \n", 482 | " \n", 483 | " \n", 484 | " \n", 485 | " \n", 486 | " \n", 487 | " \n", 488 | " \n", 489 | " \n", 490 | " \n", 491 | " \n", 492 | " \n", 493 | " \n", 494 | " \n", 495 | " \n", 496 | " \n", 497 | " \n", 498 | " \n", 499 | " \n", 500 | " \n", 501 | " \n", 502 | " \n", 503 | " \n", 504 | " \n", 505 | " \n", 506 | " \n", 507 | " \n", 508 | " \n", 509 | " \n", 510 | " \n", 511 | " \n", 512 | " \n", 513 | " \n", 514 | " \n", 515 | " \n", 516 | " \n", 517 | " \n", 518 | " \n", 519 | " \n", 520 | " \n", 521 | " \n", 522 | " \n", 523 | " \n", 524 | " \n", 525 | " \n", 526 | " \n", 527 | " \n", 528 | " \n", 529 | " \n", 530 | " \n", 531 | " \n", 532 | " \n", 533 | " \n", 534 | " \n", 535 | " \n", 536 | " \n", 537 | " \n", 538 | "
sexsmokerdaytime
0FemaleNoSunDinner
1MaleNoSunDinner
2MaleNoSunDinner
3MaleNoSunDinner
4FemaleNoSunDinner
5MaleNoSunDinner
6MaleNoSunDinner
7MaleNoSunDinner
8MaleNoSunDinner
9MaleNoSunDinner
\n", 539 | "
" 540 | ], 541 | "text/plain": [ 542 | " sex smoker day time\n", 543 | "0 Female No Sun Dinner\n", 544 | "1 Male No Sun Dinner\n", 545 | "2 Male No Sun Dinner\n", 546 | "3 Male No Sun Dinner\n", 547 | "4 Female No Sun Dinner\n", 548 | "5 Male No Sun Dinner\n", 549 | "6 Male No Sun Dinner\n", 550 | "7 Male No Sun Dinner\n", 551 | "8 Male No Sun Dinner\n", 552 | "9 Male No Sun Dinner" 553 | ] 554 | }, 555 | "metadata": { 556 | "tags": [] 557 | }, 558 | "execution_count": 10 559 | } 560 | ] 561 | }, 562 | { 563 | "cell_type": "markdown", 564 | "metadata": { 565 | "id": "bxyZFxYixaIe" 566 | }, 567 | "source": [ 568 | "vamos a empezar con la variable sexo.\r\n", 569 | "\r\n", 570 | "vamos a usar de pandas la función get_dummies()" 571 | ] 572 | }, 573 | { 574 | "cell_type": "code", 575 | "metadata": { 576 | "colab": { 577 | "base_uri": "https://localhost:8080/" 578 | }, 579 | "id": "0c6yogUdxdPS", 580 | "outputId": "9231dd4a-6e5c-4c25-bf1a-8128b78e83d4" 581 | }, 582 | "source": [ 583 | "categorica.iloc[:,0]#variable sexo" 584 | ], 585 | "execution_count": 19, 586 | "outputs": [ 587 | { 588 | "output_type": "execute_result", 589 | "data": { 590 | "text/plain": [ 591 | "0 Female\n", 592 | "1 Male\n", 593 | "2 Male\n", 594 | "3 Male\n", 595 | "4 Female\n", 596 | " ... \n", 597 | "239 Male\n", 598 | "240 Female\n", 599 | "241 Male\n", 600 | "242 Male\n", 601 | "243 Female\n", 602 | "Name: sex, Length: 244, dtype: category\n", 603 | "Categories (2, object): ['Male', 'Female']" 604 | ] 605 | }, 606 | "metadata": { 607 | "tags": [] 608 | }, 609 | "execution_count": 19 610 | } 611 | ] 612 | }, 613 | { 614 | "cell_type": "code", 615 | "metadata": { 616 | "colab": { 617 | "base_uri": "https://localhost:8080/", 618 | "height": 419 619 | }, 620 | "id": "vpqIANNUyg6E", 621 | "outputId": "ebb626fc-8eaa-4271-8eae-4faaceb59277" 622 | }, 623 | "source": [ 624 | "#usamos la función get_dummies\r\n", 625 | "cat_numerical=pd.get_dummies(categorica.iloc[:,0], drop_first=True)\r\n", 626 | "cat_numerical" 627 | ], 628 | "execution_count": 20, 629 | "outputs": [ 630 | { 631 | "output_type": "execute_result", 632 | "data": { 633 | "text/html": [ 634 | "
\n", 635 | "\n", 648 | "\n", 649 | " \n", 650 | " \n", 651 | " \n", 652 | " \n", 653 | " \n", 654 | " \n", 655 | " \n", 656 | " \n", 657 | " \n", 658 | " \n", 659 | " \n", 660 | " \n", 661 | " \n", 662 | " \n", 663 | " \n", 664 | " \n", 665 | " \n", 666 | " \n", 667 | " \n", 668 | " \n", 669 | " \n", 670 | " \n", 671 | " \n", 672 | " \n", 673 | " \n", 674 | " \n", 675 | " \n", 676 | " \n", 677 | " \n", 678 | " \n", 679 | " \n", 680 | " \n", 681 | " \n", 682 | " \n", 683 | " \n", 684 | " \n", 685 | " \n", 686 | " \n", 687 | " \n", 688 | " \n", 689 | " \n", 690 | " \n", 691 | " \n", 692 | " \n", 693 | " \n", 694 | " \n", 695 | " \n", 696 | " \n", 697 | " \n", 698 | " \n", 699 | " \n", 700 | " \n", 701 | "
Female
01
10
20
30
41
......
2390
2401
2410
2420
2431
\n", 702 | "

244 rows × 1 columns

\n", 703 | "
" 704 | ], 705 | "text/plain": [ 706 | " Female\n", 707 | "0 1\n", 708 | "1 0\n", 709 | "2 0\n", 710 | "3 0\n", 711 | "4 1\n", 712 | ".. ...\n", 713 | "239 0\n", 714 | "240 1\n", 715 | "241 0\n", 716 | "242 0\n", 717 | "243 1\n", 718 | "\n", 719 | "[244 rows x 1 columns]" 720 | ] 721 | }, 722 | "metadata": { 723 | "tags": [] 724 | }, 725 | "execution_count": 20 726 | } 727 | ] 728 | }, 729 | { 730 | "cell_type": "code", 731 | "metadata": { 732 | "colab": { 733 | "base_uri": "https://localhost:8080/", 734 | "height": 419 735 | }, 736 | "id": "WbUZRe13y8L2", 737 | "outputId": "07610f66-5e56-4b4f-bfeb-191213a07256" 738 | }, 739 | "source": [ 740 | "cat_numerical=pd.get_dummies(categorica.iloc[:,0], drop_first=False)\r\n", 741 | "cat_numerical" 742 | ], 743 | "execution_count": 21, 744 | "outputs": [ 745 | { 746 | "output_type": "execute_result", 747 | "data": { 748 | "text/html": [ 749 | "
\n", 750 | "\n", 763 | "\n", 764 | " \n", 765 | " \n", 766 | " \n", 767 | " \n", 768 | " \n", 769 | " \n", 770 | " \n", 771 | " \n", 772 | " \n", 773 | " \n", 774 | " \n", 775 | " \n", 776 | " \n", 777 | " \n", 778 | " \n", 779 | " \n", 780 | " \n", 781 | " \n", 782 | " \n", 783 | " \n", 784 | " \n", 785 | " \n", 786 | " \n", 787 | " \n", 788 | " \n", 789 | " \n", 790 | " \n", 791 | " \n", 792 | " \n", 793 | " \n", 794 | " \n", 795 | " \n", 796 | " \n", 797 | " \n", 798 | " \n", 799 | " \n", 800 | " \n", 801 | " \n", 802 | " \n", 803 | " \n", 804 | " \n", 805 | " \n", 806 | " \n", 807 | " \n", 808 | " \n", 809 | " \n", 810 | " \n", 811 | " \n", 812 | " \n", 813 | " \n", 814 | " \n", 815 | " \n", 816 | " \n", 817 | " \n", 818 | " \n", 819 | " \n", 820 | " \n", 821 | " \n", 822 | " \n", 823 | " \n", 824 | " \n", 825 | " \n", 826 | " \n", 827 | " \n", 828 | "
MaleFemale
001
110
210
310
401
.........
23910
24001
24110
24210
24301
\n", 829 | "

244 rows × 2 columns

\n", 830 | "
" 831 | ], 832 | "text/plain": [ 833 | " Male Female\n", 834 | "0 0 1\n", 835 | "1 1 0\n", 836 | "2 1 0\n", 837 | "3 1 0\n", 838 | "4 0 1\n", 839 | ".. ... ...\n", 840 | "239 1 0\n", 841 | "240 0 1\n", 842 | "241 1 0\n", 843 | "242 1 0\n", 844 | "243 0 1\n", 845 | "\n", 846 | "[244 rows x 2 columns]" 847 | ] 848 | }, 849 | "metadata": { 850 | "tags": [] 851 | }, 852 | "execution_count": 21 853 | } 854 | ] 855 | }, 856 | { 857 | "cell_type": "code", 858 | "metadata": { 859 | "colab": { 860 | "base_uri": "https://localhost:8080/", 861 | "height": 419 862 | }, 863 | "id": "P8iLcC6OzJlU", 864 | "outputId": "295e77df-6f81-4ddc-a542-3ffc4920b8bd" 865 | }, 866 | "source": [ 867 | "cat_numerical=pd.get_dummies(categorica, drop_first=True)\r\n", 868 | "cat_numerical" 869 | ], 870 | "execution_count": 23, 871 | "outputs": [ 872 | { 873 | "output_type": "execute_result", 874 | "data": { 875 | "text/html": [ 876 | "
\n", 877 | "\n", 890 | "\n", 891 | " \n", 892 | " \n", 893 | " \n", 894 | " \n", 895 | " \n", 896 | " \n", 897 | " \n", 898 | " \n", 899 | " \n", 900 | " \n", 901 | " \n", 902 | " \n", 903 | " \n", 904 | " \n", 905 | " \n", 906 | " \n", 907 | " \n", 908 | " \n", 909 | " \n", 910 | " \n", 911 | " \n", 912 | " \n", 913 | " \n", 914 | " \n", 915 | " \n", 916 | " \n", 917 | " \n", 918 | " \n", 919 | " \n", 920 | " \n", 921 | " \n", 922 | " \n", 923 | " \n", 924 | " \n", 925 | " \n", 926 | " \n", 927 | " \n", 928 | " \n", 929 | " \n", 930 | " \n", 931 | " \n", 932 | " \n", 933 | " \n", 934 | " \n", 935 | " \n", 936 | " \n", 937 | " \n", 938 | " \n", 939 | " \n", 940 | " \n", 941 | " \n", 942 | " \n", 943 | " \n", 944 | " \n", 945 | " \n", 946 | " \n", 947 | " \n", 948 | " \n", 949 | " \n", 950 | " \n", 951 | " \n", 952 | " \n", 953 | " \n", 954 | " \n", 955 | " \n", 956 | " \n", 957 | " \n", 958 | " \n", 959 | " \n", 960 | " \n", 961 | " \n", 962 | " \n", 963 | " \n", 964 | " \n", 965 | " \n", 966 | " \n", 967 | " \n", 968 | " \n", 969 | " \n", 970 | " \n", 971 | " \n", 972 | " \n", 973 | " \n", 974 | " \n", 975 | " \n", 976 | " \n", 977 | " \n", 978 | " \n", 979 | " \n", 980 | " \n", 981 | " \n", 982 | " \n", 983 | " \n", 984 | " \n", 985 | " \n", 986 | " \n", 987 | " \n", 988 | " \n", 989 | " \n", 990 | " \n", 991 | " \n", 992 | " \n", 993 | " \n", 994 | " \n", 995 | " \n", 996 | " \n", 997 | " \n", 998 | " \n", 999 | " \n", 1000 | " \n", 1001 | " \n", 1002 | " \n", 1003 | "
sex_Femalesmoker_Noday_Friday_Satday_Suntime_Dinner
0110011
1010011
2010011
3010011
4110011
.....................
239010101
240100101
241000101
242010101
243110001
\n", 1004 | "

244 rows × 6 columns

\n", 1005 | "
" 1006 | ], 1007 | "text/plain": [ 1008 | " sex_Female smoker_No day_Fri day_Sat day_Sun time_Dinner\n", 1009 | "0 1 1 0 0 1 1\n", 1010 | "1 0 1 0 0 1 1\n", 1011 | "2 0 1 0 0 1 1\n", 1012 | "3 0 1 0 0 1 1\n", 1013 | "4 1 1 0 0 1 1\n", 1014 | ".. ... ... ... ... ... ...\n", 1015 | "239 0 1 0 1 0 1\n", 1016 | "240 1 0 0 1 0 1\n", 1017 | "241 0 0 0 1 0 1\n", 1018 | "242 0 1 0 1 0 1\n", 1019 | "243 1 1 0 0 0 1\n", 1020 | "\n", 1021 | "[244 rows x 6 columns]" 1022 | ] 1023 | }, 1024 | "metadata": { 1025 | "tags": [] 1026 | }, 1027 | "execution_count": 23 1028 | } 1029 | ] 1030 | }, 1031 | { 1032 | "cell_type": "code", 1033 | "metadata": { 1034 | "colab": { 1035 | "base_uri": "https://localhost:8080/", 1036 | "height": 669 1037 | }, 1038 | "id": "VueKbQA4ze_j", 1039 | "outputId": "481f1aef-bc27-4524-e67c-0a8cf8b32cb5" 1040 | }, 1041 | "source": [ 1042 | "datos=pd.concat([numerica, cat_numerical], axis=1)\r\n", 1043 | "datos.head(20)" 1044 | ], 1045 | "execution_count": 25, 1046 | "outputs": [ 1047 | { 1048 | "output_type": "execute_result", 1049 | "data": { 1050 | "text/html": [ 1051 | "
\n", 1052 | "\n", 1065 | "\n", 1066 | " \n", 1067 | " \n", 1068 | " \n", 1069 | " \n", 1070 | " \n", 1071 | " \n", 1072 | " \n", 1073 | " \n", 1074 | " \n", 1075 | " \n", 1076 | " \n", 1077 | " \n", 1078 | " \n", 1079 | " \n", 1080 | " \n", 1081 | " \n", 1082 | " \n", 1083 | " \n", 1084 | " \n", 1085 | " \n", 1086 | " \n", 1087 | " \n", 1088 | " \n", 1089 | " \n", 1090 | " \n", 1091 | " \n", 1092 | " \n", 1093 | " \n", 1094 | " \n", 1095 | " \n", 1096 | " \n", 1097 | " \n", 1098 | " \n", 1099 | " \n", 1100 | " \n", 1101 | " \n", 1102 | " \n", 1103 | " \n", 1104 | " \n", 1105 | " \n", 1106 | " \n", 1107 | " \n", 1108 | " \n", 1109 | " \n", 1110 | " \n", 1111 | " \n", 1112 | " \n", 1113 | " \n", 1114 | " \n", 1115 | " \n", 1116 | " \n", 1117 | " \n", 1118 | " \n", 1119 | " \n", 1120 | " \n", 1121 | " \n", 1122 | " \n", 1123 | " \n", 1124 | " \n", 1125 | " \n", 1126 | " \n", 1127 | " \n", 1128 | " \n", 1129 | " \n", 1130 | " \n", 1131 | " \n", 1132 | " \n", 1133 | " \n", 1134 | " \n", 1135 | " \n", 1136 | " \n", 1137 | " \n", 1138 | " \n", 1139 | " \n", 1140 | " \n", 1141 | " \n", 1142 | " \n", 1143 | " \n", 1144 | " \n", 1145 | " \n", 1146 | " \n", 1147 | " \n", 1148 | " \n", 1149 | " \n", 1150 | " \n", 1151 | " \n", 1152 | " \n", 1153 | " \n", 1154 | " \n", 1155 | " \n", 1156 | " \n", 1157 | " \n", 1158 | " \n", 1159 | " \n", 1160 | " \n", 1161 | " \n", 1162 | " \n", 1163 | " \n", 1164 | " \n", 1165 | " \n", 1166 | " \n", 1167 | " \n", 1168 | " \n", 1169 | " \n", 1170 | " \n", 1171 | " \n", 1172 | " \n", 1173 | " \n", 1174 | " \n", 1175 | " \n", 1176 | " \n", 1177 | " \n", 1178 | " \n", 1179 | " \n", 1180 | " \n", 1181 | " \n", 1182 | " \n", 1183 | " \n", 1184 | " \n", 1185 | " \n", 1186 | " \n", 1187 | " \n", 1188 | " \n", 1189 | " \n", 1190 | " \n", 1191 | " \n", 1192 | " \n", 1193 | " \n", 1194 | " \n", 1195 | " \n", 1196 | " \n", 1197 | " \n", 1198 | " \n", 1199 | " \n", 1200 | " \n", 1201 | " \n", 1202 | " \n", 1203 | " \n", 1204 | " \n", 1205 | " \n", 1206 | " \n", 1207 | " \n", 1208 | " \n", 1209 | " \n", 1210 | " \n", 1211 | " \n", 1212 | " \n", 1213 | " \n", 1214 | " \n", 1215 | " \n", 1216 | " \n", 1217 | " \n", 1218 | " \n", 1219 | " \n", 1220 | " \n", 1221 | " \n", 1222 | " \n", 1223 | " \n", 1224 | " \n", 1225 | " \n", 1226 | " \n", 1227 | " \n", 1228 | " \n", 1229 | " \n", 1230 | " \n", 1231 | " \n", 1232 | " \n", 1233 | " \n", 1234 | " \n", 1235 | " \n", 1236 | " \n", 1237 | " \n", 1238 | " \n", 1239 | " \n", 1240 | " \n", 1241 | " \n", 1242 | " \n", 1243 | " \n", 1244 | " \n", 1245 | " \n", 1246 | " \n", 1247 | " \n", 1248 | " \n", 1249 | " \n", 1250 | " \n", 1251 | " \n", 1252 | " \n", 1253 | " \n", 1254 | " \n", 1255 | " \n", 1256 | " \n", 1257 | " \n", 1258 | " \n", 1259 | " \n", 1260 | " \n", 1261 | " \n", 1262 | " \n", 1263 | " \n", 1264 | " \n", 1265 | " \n", 1266 | " \n", 1267 | " \n", 1268 | " \n", 1269 | " \n", 1270 | " \n", 1271 | " \n", 1272 | " \n", 1273 | " \n", 1274 | " \n", 1275 | " \n", 1276 | " \n", 1277 | " \n", 1278 | " \n", 1279 | " \n", 1280 | " \n", 1281 | " \n", 1282 | " \n", 1283 | " \n", 1284 | " \n", 1285 | " \n", 1286 | " \n", 1287 | " \n", 1288 | " \n", 1289 | " \n", 1290 | " \n", 1291 | " \n", 1292 | " \n", 1293 | " \n", 1294 | " \n", 1295 | " \n", 1296 | " \n", 1297 | " \n", 1298 | " \n", 1299 | " \n", 1300 | " \n", 1301 | " \n", 1302 | " \n", 1303 | " \n", 1304 | " \n", 1305 | " \n", 1306 | " \n", 1307 | " \n", 1308 | " \n", 1309 | " \n", 1310 | " \n", 1311 | " \n", 1312 | " \n", 1313 | " \n", 1314 | " \n", 1315 | " \n", 1316 | " \n", 1317 | " \n", 1318 | " \n", 1319 | " \n", 1320 | " \n", 1321 | " \n", 1322 | "
total_billtipsizesex_Femalesmoker_Noday_Friday_Satday_Suntime_Dinner
016.991.012110011
110.341.663010011
221.013.503010011
323.683.312010011
424.593.614110011
525.294.714010011
68.772.002010011
726.883.124010011
815.041.962010011
914.783.232010011
1010.271.712010011
1135.265.004110011
1215.421.572010011
1318.433.004010011
1414.833.022110011
1521.583.922010011
1610.331.673110011
1716.293.713010011
1816.973.503110011
1920.653.353010101
\n", 1323 | "
" 1324 | ], 1325 | "text/plain": [ 1326 | " total_bill tip size sex_Female ... day_Fri day_Sat day_Sun time_Dinner\n", 1327 | "0 16.99 1.01 2 1 ... 0 0 1 1\n", 1328 | "1 10.34 1.66 3 0 ... 0 0 1 1\n", 1329 | "2 21.01 3.50 3 0 ... 0 0 1 1\n", 1330 | "3 23.68 3.31 2 0 ... 0 0 1 1\n", 1331 | "4 24.59 3.61 4 1 ... 0 0 1 1\n", 1332 | "5 25.29 4.71 4 0 ... 0 0 1 1\n", 1333 | "6 8.77 2.00 2 0 ... 0 0 1 1\n", 1334 | "7 26.88 3.12 4 0 ... 0 0 1 1\n", 1335 | "8 15.04 1.96 2 0 ... 0 0 1 1\n", 1336 | "9 14.78 3.23 2 0 ... 0 0 1 1\n", 1337 | "10 10.27 1.71 2 0 ... 0 0 1 1\n", 1338 | "11 35.26 5.00 4 1 ... 0 0 1 1\n", 1339 | "12 15.42 1.57 2 0 ... 0 0 1 1\n", 1340 | "13 18.43 3.00 4 0 ... 0 0 1 1\n", 1341 | "14 14.83 3.02 2 1 ... 0 0 1 1\n", 1342 | "15 21.58 3.92 2 0 ... 0 0 1 1\n", 1343 | "16 10.33 1.67 3 1 ... 0 0 1 1\n", 1344 | "17 16.29 3.71 3 0 ... 0 0 1 1\n", 1345 | "18 16.97 3.50 3 1 ... 0 0 1 1\n", 1346 | "19 20.65 3.35 3 0 ... 0 1 0 1\n", 1347 | "\n", 1348 | "[20 rows x 9 columns]" 1349 | ] 1350 | }, 1351 | "metadata": { 1352 | "tags": [] 1353 | }, 1354 | "execution_count": 25 1355 | } 1356 | ] 1357 | } 1358 | ] 1359 | } --------------------------------------------------------------------------------