ibnummuhammad
commited on
Commit
•
90e79c8
1
Parent(s):
5cecc14
Add 'Implementing the model'
Browse files
forecasting_logistic_regression.ipynb
CHANGED
@@ -342,7 +342,7 @@
|
|
342 |
"name": "stderr",
|
343 |
"output_type": "stream",
|
344 |
"text": [
|
345 |
-
"/var/folders/fj/ycln97zn6b1ckstg6ksdmgl80000gp/T/
|
346 |
"\n",
|
347 |
"Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.\n",
|
348 |
"\n",
|
@@ -1399,7 +1399,7 @@
|
|
1399 |
},
|
1400 |
{
|
1401 |
"cell_type": "code",
|
1402 |
-
"execution_count":
|
1403 |
"metadata": {},
|
1404 |
"outputs": [
|
1405 |
{
|
@@ -1544,6 +1544,76 @@
|
|
1544 |
"print(rfe.ranking_)"
|
1545 |
]
|
1546 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1547 |
{
|
1548 |
"cell_type": "code",
|
1549 |
"execution_count": null,
|
|
|
342 |
"name": "stderr",
|
343 |
"output_type": "stream",
|
344 |
"text": [
|
345 |
+
"/var/folders/fj/ycln97zn6b1ckstg6ksdmgl80000gp/T/ipykernel_62188/2225886973.py:1: FutureWarning: \n",
|
346 |
"\n",
|
347 |
"Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.\n",
|
348 |
"\n",
|
|
|
1399 |
},
|
1400 |
{
|
1401 |
"cell_type": "code",
|
1402 |
+
"execution_count": 24,
|
1403 |
"metadata": {},
|
1404 |
"outputs": [
|
1405 |
{
|
|
|
1544 |
"print(rfe.ranking_)"
|
1545 |
]
|
1546 |
},
|
1547 |
+
{
|
1548 |
+
"cell_type": "code",
|
1549 |
+
"execution_count": 25,
|
1550 |
+
"metadata": {},
|
1551 |
+
"outputs": [],
|
1552 |
+
"source": [
|
1553 |
+
"cols=['euribor3m', 'job_blue-collar', 'job_housemaid', 'marital_unknown', 'education_illiterate', 'default_no', 'default_unknown', \n",
|
1554 |
+
" 'contact_cellular', 'contact_telephone', 'month_apr', 'month_aug', 'month_dec', 'month_jul', 'month_jun', 'month_mar', \n",
|
1555 |
+
" 'month_may', 'month_nov', 'month_oct', \"poutcome_failure\", \"poutcome_success\"] \n",
|
1556 |
+
"X=os_data_X[cols]\n",
|
1557 |
+
"y=os_data_y['y']"
|
1558 |
+
]
|
1559 |
+
},
|
1560 |
+
{
|
1561 |
+
"cell_type": "code",
|
1562 |
+
"execution_count": 27,
|
1563 |
+
"metadata": {},
|
1564 |
+
"outputs": [
|
1565 |
+
{
|
1566 |
+
"name": "stdout",
|
1567 |
+
"output_type": "stream",
|
1568 |
+
"text": [
|
1569 |
+
"Optimization terminated successfully.\n",
|
1570 |
+
" Current function value: 0.442547\n",
|
1571 |
+
" Iterations 7\n",
|
1572 |
+
" Results: Logit\n",
|
1573 |
+
"=====================================================================\n",
|
1574 |
+
"Model: Logit Method: MLE \n",
|
1575 |
+
"Dependent Variable: y Pseudo R-squared: 0.362 \n",
|
1576 |
+
"Date: 2024-04-06 21:11 AIC: 45298.4477\n",
|
1577 |
+
"No. Observations: 51134 BIC: 45475.2918\n",
|
1578 |
+
"Df Model: 19 Log-Likelihood: -22629. \n",
|
1579 |
+
"Df Residuals: 51114 LL-Null: -35443. \n",
|
1580 |
+
"Converged: 1.0000 LLR p-value: 0.0000 \n",
|
1581 |
+
"No. Iterations: 7.0000 Scale: 1.0000 \n",
|
1582 |
+
"---------------------------------------------------------------------\n",
|
1583 |
+
" Coef. Std.Err. z P>|z| [0.025 0.975]\n",
|
1584 |
+
"---------------------------------------------------------------------\n",
|
1585 |
+
"euribor3m -0.9276 0.0104 -89.3986 0.0000 -0.9479 -0.9072\n",
|
1586 |
+
"job_blue-collar 0.2944 0.0276 10.6790 0.0000 0.2403 0.3484\n",
|
1587 |
+
"job_housemaid 0.3491 0.0719 4.8587 0.0000 0.2083 0.4900\n",
|
1588 |
+
"marital_unknown 0.7634 0.2170 3.5179 0.0004 0.3381 1.1887\n",
|
1589 |
+
"education_illiterate 1.8983 0.3669 5.1738 0.0000 1.1792 2.6175\n",
|
1590 |
+
"default_no 0.7756 0.0479 16.2049 0.0000 0.6818 0.8694\n",
|
1591 |
+
"default_unknown 0.8449 0.0455 18.5609 0.0000 0.7556 0.9341\n",
|
1592 |
+
"contact_cellular -0.8155 0.0511 -15.9708 0.0000 -0.9156 -0.7154\n",
|
1593 |
+
"contact_telephone 0.3087 0.0498 6.1957 0.0000 0.2110 0.4063\n",
|
1594 |
+
"month_apr 1.6227 0.0459 35.3165 0.0000 1.5326 1.7127\n",
|
1595 |
+
"month_aug 2.8544 0.0543 52.5638 0.0000 2.7479 2.9608\n",
|
1596 |
+
"month_dec 1.8739 0.1338 14.0063 0.0000 1.6117 2.1362\n",
|
1597 |
+
"month_jul 3.2465 0.0537 60.4650 0.0000 3.1412 3.3517\n",
|
1598 |
+
"month_jun 2.0927 0.0497 42.0806 0.0000 1.9952 2.1902\n",
|
1599 |
+
"month_mar 2.6971 0.0833 32.3795 0.0000 2.5338 2.8603\n",
|
1600 |
+
"month_may 1.0958 0.0416 26.3248 0.0000 1.0143 1.1774\n",
|
1601 |
+
"month_nov 2.7162 0.0544 49.9173 0.0000 2.6096 2.8229\n",
|
1602 |
+
"month_oct 2.8007 0.0794 35.2615 0.0000 2.6450 2.9564\n",
|
1603 |
+
"poutcome_failure -0.3545 0.0344 -10.3019 0.0000 -0.4220 -0.2871\n",
|
1604 |
+
"poutcome_success 1.2213 0.0649 18.8104 0.0000 1.0941 1.3486\n",
|
1605 |
+
"=====================================================================\n",
|
1606 |
+
"\n"
|
1607 |
+
]
|
1608 |
+
}
|
1609 |
+
],
|
1610 |
+
"source": [
|
1611 |
+
"import statsmodels.api as sm\n",
|
1612 |
+
"logit_model=sm.Logit(y,X.astype(float))\n",
|
1613 |
+
"result=logit_model.fit()\n",
|
1614 |
+
"print(result.summary2())"
|
1615 |
+
]
|
1616 |
+
},
|
1617 |
{
|
1618 |
"cell_type": "code",
|
1619 |
"execution_count": null,
|