Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Updated the libraries #80

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
76 changes: 76 additions & 0 deletions form_configs/churn_detection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"Churn Detection Form": {
"Credit Score": {
"type": "number",
"min_value": 0,
"max_value": 1000,
"default_value": 0,
"step": 10,
"field_name": "cs"
},
"Geography": {
"type": "dropdown",
"options": ["France", "Germany","Spain"],
"default_value": "France",
"field_name": "geo"
},
"Gender": {
"type": "dropdown",
"options": ["Female", "Male"],
"default_value": "Female",
"field_name": "gen"
},
"Age": {
"type": "number",
"min_value": 0,
"max_value": 100,
"default_value": 0,
"step": 1,
"field_name": "age"
},
"Tenure": {
"type": "number",
"min_value": 0,
"max_value": 30,
"default_value": 0,
"step": 1,
"field_name": "tenure"
},
"Balance": {
"type": "float",
"min_value": 0.0,
"max_value": 1000000.0,
"default_value": 0.0,
"step": 100.5,
"field_name": "bal"
},
"Number Of Products": {
"type": "number",
"min_value": 0,
"max_value": 10,
"default_value": 0,
"step": 1,
"field_name": "nop"
},
"Has Credit Card": {
"type": "dropdown",
"field_name": "hcc",
"options": [0,1],
"default_value": 0
},
"Is Active Member": {
"type": "dropdown",
"field_name": "iam",
"options": [0,1],
"default_value": 0
},
"Estimated Salary": {
"type": "float",
"min_value": 0.0,
"max_value": 1000000.0,
"default_value": 0.0,
"step": 100.5,
"field_name": "es"
}
}
}
17 changes: 17 additions & 0 deletions models/Customer_Churn_Prediction/Model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import joblib
import numpy as np
model = joblib.load('models/Customer_Churn_Prediction/saved_models/Gradient_Boosting_Classifier.joblib')
scaler = joblib.load('models/Customer_Churn_Prediction/saved_models/scaler.joblib')
def customer_churn_prediction(cs,geo,gen,age,tenure,bal,nop,hcc,iam,es):
features = {'CreditScore':cs,'Geography':geo,'Gender':gen,'Age':age,'Tenure':tenure,'Balance':bal,'NumOfProducts':nop,'HasCrCard':hcc,'IsActiveMember':iam,'EstimatedSalary':es}
geography_map = {'France': 0, 'Spain': 1, 'Germany': 2}
gender_map = {'Female': 0, 'Male': 1}
features['Geography'] = geography_map[features['Geography']]
features['Gender'] = gender_map[features['Gender']]
input_array = np.array(list(features.values())).reshape(1, -1)
scaled_input = scaler.transform(input_array)
preprocessed_input = scaled_input
prediction = model.predict(preprocessed_input)
probability = model.predict_proba(preprocessed_input)[0][1]
print(prediction)
return prediction[0], probability
9 changes: 9 additions & 0 deletions models/Customer_Churn_Prediction/Predict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from models.Customer_Churn_Prediction.Model import customer_churn_prediction
def get_prediction(cs,geo,gen,age,tenure,bal,nop,hcc,iam,es):
prediction,probability=customer_churn_prediction(cs,geo,gen,age,tenure,bal,nop,hcc,iam,es)
output=""
if prediction == 1:
output=f"The customer is likely to churn with a probability of {probability:.2f}"
else:
output=f"The customer is likely to stay with a probability of {1-probability:.2f}"
return output
10,001 changes: 10,001 additions & 0 deletions models/Customer_Churn_Prediction/data/Churn_Modelling.csv

Large diffs are not rendered by default.

Loading