This project aims to develop a predictive model for customer churn using logistic regression. Customer churn refers to the loss of customers over time, and predicting this behavior is crucial for businesses to enhance customer retention and increase profitability. The project involves systematic steps, including data exploration, preprocessing, model development, evaluation, and tuning.
The project is organized into the following sections:
-
Introduction
- Project Overview: Briefly describes the project's goal to predict customer churn.
- Problem Statement: Defines the business problem and the importance of predicting churn.
- Dataset Description: Provides details about the dataset used, including features and the target variable.
-
Import Libraries
- Lists all the Python libraries and packages required for data manipulation, model building, and evaluation.
-
Data Loading and Exploration
- Load the Dataset: Loads the Telco Customer Churn dataset into a pandas DataFrame.
- Display Basic Information: Provides an overview of the dataset structure, including the number of rows and columns.
- Summary Statistics: Presents detailed statistics about the dataset to understand the distribution of features.
-
Data Preprocessing
- Handle Missing Values: Addresses any missing data within the dataset.
- Encode Categorical Variables: Converts categorical variables into a format suitable for modeling.
- Feature Scaling: Scales numerical features to standardize them for the logistic regression model.
-
Data Splitting
- Train-Validation-Test Split: Splits the data into training, validation, and test sets.
- Feature and Target Split: Separates the independent variables (features) from the dependent variable (target).
-
Model Definition and Training
- Define the Logistic Regression Model: Sets up the logistic regression model using Scikit-learn.
- Train the Model: Fits the model on the training data.
- Evaluate on Validation Set: Assesses the model's performance using validation data.
-
Hyperparameter Tuning
- Explores different hyperparameter values to optimize the model's performance.
-
Model Evaluation
- Confusion Matrix and Scores: Evaluates the model using metrics such as accuracy, precision, recall, and F1 score.
- ROC Curve: Analyzes the model's performance across different thresholds.
-
Conclusion and Future Work
- Summarizes the key findings of the project and suggests directions for future improvement, including potential enhancements and real-time deployment.
To run the notebook and reproduce the results, ensure you have the following dependencies installed:
- Python 3.x
- Jupyter Notebook
- Pandas
- NumPy
- Scikit-learn
- Matplotlib
You can install the required packages using:
pip install -r requirements.txt
jupyter notebook CustomerChurn.ipynbResults
The logistic regression model developed in this project provides a solid baseline for predicting customer churn. The evaluation metrics indicate that the model balances precision and recall effectively, making it suitable for identifying customers at risk of churning. Future work includes exploring more complex models and optimizing the decision threshold for business-specific needs.
Contributing
If you wish to contribute to this project, please fork the repository and submit a pull request. For major changes, please open an issue to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.