Spaces:
Runtime error
Runtime error
models updated
Browse files- Decision_Tree.pkl +3 -0
- Logistic_Regression.pkl +3 -0
- Neural_Network.pkl +3 -0
- Pycaret_Best.pkl +3 -0
- Random_Forest.pkl +3 -0
- Support_Vector_Machine.pkl +3 -0
- Support_Vector_Machine_Optimized.pkl +3 -0
- app.py +42 -20
- lr.sav +0 -0
Decision_Tree.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bd74add73292c3c2e13ae449fccb13adff435991b047b1b36dc131193c1223ef
|
3 |
+
size 43285
|
Logistic_Regression.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:17fc47b03f6713cd89e45e5802a88f0cc4ee50a80fd69c00b61cade81c772872
|
3 |
+
size 1656
|
Neural_Network.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:08d2cfbd6226d8d4c031c51c78140dfb38c2d918fb674f7bc5840930a2e3b11e
|
3 |
+
size 73970
|
Pycaret_Best.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1194ab6f7177b92d1c3573edfd069b9b6f314c74335ce94be925bb6f00441a2b
|
3 |
+
size 16937901
|
Random_Forest.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0cca312143c3f831f22e4242fe9cc1deffcf915d642f912d36300626baf0eb7a
|
3 |
+
size 6095186
|
Support_Vector_Machine.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:99ee2cb377c604dde52a44375e39d37bbd118ec7fe587cd63055f550424a0310
|
3 |
+
size 384281
|
Support_Vector_Machine_Optimized.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:968e596bb78ff711f9a98ab3d88ff75d569adfd013c4682140a973c8c2b0a3fa
|
3 |
+
size 343378
|
app.py
CHANGED
@@ -1,38 +1,60 @@
|
|
1 |
import streamlit as st
|
2 |
from pybanking.churn_prediction import model_churn
|
3 |
-
import pandas as pd
|
4 |
import pickle
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
df = model_churn.get_data()
|
|
|
9 |
st.dataframe(df.head(5))
|
10 |
|
11 |
model_names = [
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
option = st.selectbox(
|
20 |
-
'
|
21 |
-
model_names
|
|
|
22 |
|
23 |
-
|
24 |
-
loaded_model = pickle.load(open(filename, 'rb'))
|
25 |
|
26 |
-
|
27 |
|
|
|
28 |
|
29 |
option2 = st.selectbox(
|
30 |
'Which dataset would you like to use for prediction?',
|
31 |
-
['Sample
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
-
X, y = model_churn.preprocess_inputs(df)
|
35 |
st.dataframe(X.head(5))
|
36 |
-
result = loaded_model.score(X, y)
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from pybanking.churn_prediction import model_churn
|
|
|
3 |
import pickle
|
4 |
+
import sklearn.metrics as metrics
|
5 |
+
from mlxtend.plotting import plot_confusion_matrix
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
+
|
8 |
+
st.set_page_config(page_title="Customer Churn Prediction Model")
|
9 |
+
|
10 |
+
st.title('Customer Churn Prediction Model')
|
11 |
+
# x = st.slider('Select a value')
|
12 |
+
|
13 |
+
st.subheader('This is the Sample Data')
|
14 |
|
15 |
df = model_churn.get_data()
|
16 |
+
|
17 |
st.dataframe(df.head(5))
|
18 |
|
19 |
model_names = [
|
20 |
+
"Logistic_Regression",
|
21 |
+
"Support_Vector_Machine",
|
22 |
+
"Support_Vector_Machine_Optimized",
|
23 |
+
"Decision_Tree",
|
24 |
+
"Neural_Network",
|
25 |
+
"Random_Forest",
|
26 |
+
"Pycaret_Best"
|
27 |
+
]
|
28 |
+
|
29 |
option = st.selectbox(
|
30 |
+
'Select a model to be used',
|
31 |
+
model_names
|
32 |
+
)
|
33 |
|
34 |
+
st.write("Model Loaded : ", option)
|
|
|
35 |
|
36 |
+
X, y = model_churn.preprocess_inputs(df, option)
|
37 |
|
38 |
+
model = pickle.load(open(option+'.pkl', 'rb'))
|
39 |
|
40 |
option2 = st.selectbox(
|
41 |
'Which dataset would you like to use for prediction?',
|
42 |
+
['Sample Dataset', 'Upload Custom']
|
43 |
+
)
|
44 |
+
|
45 |
+
if option2 == 'Upload custom':
|
46 |
+
model = model_churn.train(df, model)
|
47 |
|
|
|
48 |
st.dataframe(X.head(5))
|
|
|
49 |
|
50 |
+
y_pred = model.predict(X)
|
51 |
+
|
52 |
+
st.write("Accuracy:",metrics.accuracy_score(y, y_pred))
|
53 |
+
st.write("Precision:",metrics.precision_score(y, y_pred))
|
54 |
+
st.write("Recall:",metrics.recall_score(y, y_pred))
|
55 |
+
|
56 |
+
fig, ax = plot_confusion_matrix(conf_mat=metrics.confusion_matrix(y, y_pred), figsize=(6, 6), cmap=plt.cm.Reds, colorbar=True)
|
57 |
+
plt.xlabel('Predictions', fontsize=18)
|
58 |
+
plt.ylabel('Actuals', fontsize=18)
|
59 |
+
plt.title('Confusion Matrix', fontsize=18)
|
60 |
+
st.pyplot(fig)
|
lr.sav
DELETED
Binary file (1.4 kB)
|
|