Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions lab-logistic-regression-with-python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'piplite'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[1], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpiplite\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m piplite\u001b[38;5;241m.\u001b[39minstall([\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpandas\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m piplite\u001b[38;5;241m.\u001b[39minstall([\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmatplotlib\u001b[39m\u001b[38;5;124m'\u001b[39m])\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'piplite'"
]
}
],
"source": [
"import piplite\n",
"await piplite.install(['pandas'])\n",
Expand Down Expand Up @@ -339,7 +351,14 @@
},
"outputs": [],
"source": [
"# write your code here\n"
"\n",
"rows, cols = churn_df.shape\n",
"print(f\"Number of rows: {rows}\")\n",
"print(f\"Number of columns: {cols}\")\n",
"\n",
"\n",
"print(\"Column names:\")\n",
"print(churn_df.columns.tolist())"
]
},
{
Expand Down Expand Up @@ -665,7 +684,16 @@
"metadata": {},
"outputs": [],
"source": [
"# write your code here\n",
"from sklearn.linear_model import LogisticRegression\n",
"from sklearn.metrics import log_loss\n",
"\n",
"LR_new = LogisticRegression(C=0.1, solver='saga').fit(X_train, y_train)\n",
"\n",
"yhat_prob_new = LR_new.predict_proba(X_test)\n",
"\n",
"log_loss_value = log_loss(y_test, yhat_prob_new)\n",
"\n",
"print(f\"New Log Loss value: {log_loss_value:.4f}\")\n",
"\n"
]
},
Expand Down Expand Up @@ -709,7 +737,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.11"
},
"widgets": {
"state": {},
Expand Down