Overview This project focuses on predicting customer churn using machine learning. It involves data preprocessing, model training, and evaluation to identify customers likely to churn. The model is built with TensorFlow and Keras, while data manipulation and visualization are handled using Pandas, scikit-learn, and Matplotlib.
β’ Overview
β’ Technologies Used
β’ Setup
β’ Data
β’ Model
β’ Evaluation
β’ Usage
β’ Contributing
β’ License
β’ TensorFlow π§ : For building and training the neural network model.
β’ Keras ποΈ: High-level API for creating neural network layers.
β’ Pandas π: Data manipulation and preprocessing.
β’ scikit-learn π¬: For model evaluation and metrics.
β’ Matplotlib π: For visualizing data and evaluation metrics.
β’ Seaborn π: For enhanced data visualization.
Prerequisites Install the required Python packages:
pip install tensorflow numpy pandas scikit-learn seaborn matplotlib
The dataset includes customer details such as:
β’ Tenure
β’ Monthly Charges
β’ Customer Service Features
A neural network model with the following architecture:
β’ Input Layer: Dense layer with 26 neurons, ReLU activation function.
β’ Hidden Layer: Dense layer with 15 neurons, ReLU activation function.
β’ Output Layer: Dense layer with 1 neuron, Sigmoid activation function.
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
model = Sequential([
Dense(26, input_shape=(26,), activation='relu'),
Dense(15, activation='relu'),
Dense(1, activation='sigmoid')
])
The model is evaluated using:
β’ Confusion Matrix: To visualize model performance.
β’ Classification Report: Provides precision, recall, and F1-score metrics.
from sklearn.metrics import confusion_matrix, classification_report
import seaborn as sns
import matplotlib.pyplot as plt
cm = confusion_matrix(y_test, y_pred)
plt.figure(figsize=(10, 7))
sns.heatmap(cm, annot=True, fmt='d', cmap='Blues')
plt.xlabel('Predicted')
plt.ylabel('Truth')
plt.title('Confusion Matrix')
plt.show()
print(classification_report(y_test, y_pred))
To train and evaluate the model, run:
python main.py
Contributions are welcome! Please:
-
Fork the repository π΄
-
Create a new branch (git checkout -b feature-branch) πΏ
-
Commit your changes (git commit -am 'Add new feature') π
-
Push to the branch (git push origin feature-branch) π
-
Create a Pull Request π¬