File size: 2,741 Bytes
fa0dd39
 
aa95367
fa0dd39
 
71b329b
fa0dd39
71b329b
fa0dd39
 
 
 
 
aa95367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
title: DSA Project
emoji: πŸ“ˆ
colorFrom: pink
colorTo: purple
sdk: gradio
sdk_version: 5.25.2
app_file: app_gradio.py
pinned: false
short_description: Customer Churn Analysis and Prediction
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

# Customer Churn Prediction Application

This application predicts customer churn based on various customer attributes using a machine learning model.

## Overview

Customer churn prediction is a critical task for businesses to identify customers who are likely to discontinue using their products or services. This application uses a Random Forest model trained on historical customer data to predict churn likelihood.

## Features

- Interactive web interface for making churn predictions
- Input validation and error handling
- Visualization of model performance through ROC curve
- Probability-based risk assessment
- Easy-to-use sliders and dropdown menus for data input

## Installation

### Prerequisites

- Python 3.8 or higher
- Required packages (see requirements.txt)

### Setup

To run this application on your local machine:

1. Clone this Space
2. Install the required packages:
   ```
   pip install -r requirements.txt
   ```
3. Run the application:
   ```
   streamlit run app.py
   ```

## Usage

1. Adjust the sliders and select options to input customer information:
   - Age
   - Gender
   - Tenure (months)
   - Usage Frequency
   - Support Calls
   - Payment Delay
   - Last Interaction (days ago)
   - Total Spend
   - Subscription Type
   - Contract Length

2. Click "Predict Churn" to see the prediction results.

3. The application will display:
   - Churn prediction (Yes/No)
   - Churn probability (0.00-1.00)
   - Risk level (Low/Medium/High)
   - ROC curve visualization showing model performance

## Model Information

The prediction model (`best_model.pkl`) is a trained Random Forest classifier that has been optimized for churn prediction. The model was trained on historical customer data with features including demographic information, usage patterns, and financial metrics.

## Deployment

This application can be deployed on Hugging Face Spaces:

1. Create a new Space on [Hugging Face](https://huggingface.co/spaces)
2. Select Streamlit or Gradio as the SDK
3. Upload the necessary files:
   - `app.py` (or `app_gradio.py`)
   - `best_model.pkl`
   - `roc_curve_rf_tuned.png`
   - `requirements.txt`

## Files Description

- `app.py`: Streamlit application code
- `app_gradio.py`: Gradio application code (alternative interface)
- `best_model.pkl`: Trained machine learning model
- `roc_curve_rf_tuned.png`: ROC curve visualization of model performance
- `requirements.txt`: List of Python dependencies