In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
\n",
- "
\n",
- " \n",
- " Parameters\n",
- "
\n",
- " \n",
- " \n",
- "
\n",
- "
\n",
- "
penalty
\n",
- "
'l2'
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
dual
\n",
- "
False
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
tol
\n",
- "
0.0001
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
C
\n",
- "
1.0
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
fit_intercept
\n",
- "
True
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
intercept_scaling
\n",
- "
1
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
class_weight
\n",
- "
'balanced'
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
random_state
\n",
- "
None
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
solver
\n",
- "
'lbfgs'
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
max_iter
\n",
- "
100
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
multi_class
\n",
- "
'deprecated'
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
verbose
\n",
- "
0
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
warm_start
\n",
- "
False
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
n_jobs
\n",
- "
None
\n",
- "
\n",
- " \n",
- "\n",
- "
\n",
- "
\n",
- "
l1_ratio
\n",
- "
None
\n",
- "
\n",
- " \n",
- " \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ]
- },
- "execution_count": 15,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "execution_count": 15
- },
- {
- "metadata": {
- "ExecuteTime": {
- "end_time": "2025-09-21T07:51:59.892241Z",
- "start_time": "2025-09-21T07:51:59.884892Z"
- }
- },
- "cell_type": "code",
- "source": [
- "# Make predictions\n",
- "y_pred = model.predict(X_test)"
- ],
- "id": "15510ca63305d3a8",
- "outputs": [],
- "execution_count": 16
- },
- {
- "metadata": {
- "ExecuteTime": {
- "end_time": "2025-09-21T07:51:59.909894Z",
- "start_time": "2025-09-21T07:51:59.903069Z"
- }
- },
- "cell_type": "code",
- "source": [
- "from sklearn.metrics import accuracy_score\n",
- "\n",
- "accuracy = accuracy_score(y_test, y_pred)\n",
- "print(f\"Accuracy: {accuracy:.4f} ({accuracy*100:.2f}%)\")"
- ],
- "id": "7f06c5a38d67361b",
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Accuracy: 0.7473 (74.73%)\n"
- ]
- }
- ],
- "execution_count": 17
- },
- {
- "metadata": {
- "ExecuteTime": {
- "end_time": "2025-09-21T07:51:59.941200Z",
- "start_time": "2025-09-21T07:51:59.922375Z"
- }
- },
- "cell_type": "code",
- "source": [
- "from sklearn.metrics import classification_report,confusion_matrix, accuracy_score\n",
- "\n",
- "print(\"Classification Report:\")\n",
- "print(classification_report(y_test, y_pred))\n",
- "print(\"\\nConfusion Matrix:\")\n",
- "print(confusion_matrix(y_test, y_pred))\n",
- "# Accuracy\n"
- ],
- "id": "17e1612821887886",
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Classification Report:\n",
- " precision recall f1-score support\n",
- "\n",
- " 0 0.92 0.72 0.81 1036\n",
- " 1 0.51 0.82 0.63 373\n",
- "\n",
- " accuracy 0.75 1409\n",
- " macro avg 0.72 0.77 0.72 1409\n",
- "weighted avg 0.81 0.75 0.76 1409\n",
- "\n",
- "\n",
- "Confusion Matrix:\n",
- "[[749 287]\n",
- " [ 69 304]]\n"
- ]
- }
- ],
- "execution_count": 18
- },
- {
- "metadata": {
- "ExecuteTime": {
- "end_time": "2025-09-21T07:51:59.968133Z",
- "start_time": "2025-09-21T07:51:59.955198Z"
- }
- },
- "cell_type": "code",
- "source": [
- "# Quick check\n",
- "train_acc = model.score(X_train, y_train)\n",
- "test_acc = model.score(X_test, y_test)\n",
- "\n",
- "print(f\"Training Accuracy: {train_acc:.4f}\")\n",
- "print(f\"Test Accuracy: {test_acc:.4f}\")\n",
- "print(f\"Difference: {train_acc - test_acc:.4f}\")\n",
- "\n",
- "if train_acc - test_acc > 0.1: # 10% difference\n",
- " print(\"OVERFITTING: Training accuracy much higher than test!\")\n",
- "elif train_acc - test_acc > 0.05: # 5% difference\n",
- " print(\"Possible overfitting\")\n",
- "else:\n",
- " print(\"Good generalization\")"
- ],
- "id": "6733660e55b07d6a",
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Training Accuracy: 0.7448\n",
- "Test Accuracy: 0.7473\n",
- "Difference: -0.0026\n",
- "Good generalization\n"
- ]
- }
- ],
- "execution_count": 19
- },
- {
- "metadata": {},
- "cell_type": "markdown",
- "source": "##### No Churn: 0.72 → Model correctly identifies 72% of customers who actually didn't churn. Churn: 0.82 → Model correctly identifies 82% of customers who actually churned this we get from the recall value that is currently needed for the model ,So i given more priority for Recall than the precision.In precision for Churned customers we are getting only 51% accuracy that means we are doing false alarms on our loayal customers but according to business we got a recall of 82% that is we are able to find the customers who is going to churn.",
- "id": "45ee6471491777de"
- },
- {
- "metadata": {},
- "cell_type": "markdown",
- "source": "##### precision-whats my prediction and what has happend really ie,if i predicted 100 and i got correct as 51 so my precision is 51%",
- "id": "b071e7356fcbce1b"
- },
- {
- "metadata": {},
- "cell_type": "markdown",
- "source": "##### Recall-whats has orginally happend and inside that how much i predicted ie,if there are 100 actually churned and i got a prediction of 82 so my recall is 82%",
- "id": "b4a0bf637e18cc7e"
- },
- {
- "metadata": {},
- "cell_type": "markdown",
- "source": [
- "\n",
- "##### So in my perspective Recall is more important for this modal because its identifying 82% percent of churned ones\n"
- ],
- "id": "695ecdd9397942da"
- },
- {
- "metadata": {},
- "cell_type": "markdown",
- "source": "##### Model is very good in predicting the churned ones so that we can",
- "id": "851da7895fe038d8"
- },
- {
- "metadata": {},
- "cell_type": "markdown",
- "source": [
- "#### Over all performance of the model is 75% ie,our model correctly predicts 75% of all customers.For non churning customers Precision: 92% - When you predict \"won't churn\", we are almost always right.Recall: 72% - You catch 72% of customers who actually stay.Our Model is giving Strong performance for identifying loyal customers.For Churned customers Precision: 51% - Only half your churn predictions are correct Recall: 82% - our catches 82% of customers who actually churn Good at finding churners, but many false alarms.\n",
- "#### Strong areas of our model are\n",
- "##### 1).Excellent churn detection (82% recall) - You won't miss many leaving customers\n",
- "##### 2). High confidence in loyal customers (92% precision for non-churn)\n",
- "##### 3).Actionable for retention campaigns\n"
- ],
- "id": "ada9ea863b911e24"
- }
- ],
- "metadata": {
- "language_info": {
- "name": "python"
- },
- "kernelspec": {
- "name": "python3",
- "language": "python",
- "display_name": "Python 3 (ipykernel)"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}