Spaces:
Runtime error
Runtime error
models added
Browse files
app.py
CHANGED
@@ -1,21 +1,57 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
|
|
3 |
import pickle
|
|
|
|
|
|
|
4 |
import sklearn.metrics as metrics
|
5 |
from mlxtend.plotting import plot_confusion_matrix
|
6 |
-
import
|
|
|
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",
|
@@ -31,21 +67,18 @@ option = st.selectbox(
|
|
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.
|
|
|
|
|
49 |
|
50 |
y_pred = model.predict(X)
|
51 |
|
|
|
1 |
import streamlit as st
|
2 |
+
import streamlit.components.v1 as components
|
3 |
+
import pandas as pd
|
4 |
import pickle
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
from pybanking.churn_prediction import model_churn
|
7 |
+
from pybanking.EDA import data_analysis
|
8 |
import sklearn.metrics as metrics
|
9 |
from mlxtend.plotting import plot_confusion_matrix
|
10 |
+
import streamlit.components.v1 as components
|
11 |
+
import webbrowser
|
12 |
|
13 |
st.set_page_config(page_title="Customer Churn Prediction Model")
|
14 |
|
15 |
st.title('Customer Churn Prediction Model')
|
|
|
|
|
|
|
16 |
|
17 |
df = model_churn.get_data()
|
18 |
|
19 |
+
option2 = st.selectbox(
|
20 |
+
'Which dataset would you like to use for prediction?',
|
21 |
+
['Sample Dataset', 'Upload Custom']
|
22 |
+
)
|
23 |
+
|
24 |
+
if option2 == 'Upload Custom':
|
25 |
+
file = st.file_uploader("Choose a file")
|
26 |
+
if file is not None:
|
27 |
+
#read csv
|
28 |
+
df = pd.read_csv(file)
|
29 |
+
else:
|
30 |
+
st.warning("you need to upload a csv file.")
|
31 |
+
|
32 |
+
st.subheader('This is the Selected Data')
|
33 |
+
|
34 |
st.dataframe(df.head(5))
|
35 |
|
36 |
+
analysis_class = data_analysis.Analysis()
|
37 |
+
|
38 |
+
option3 = st.selectbox(
|
39 |
+
'Select Exploratory Data Analysis type',
|
40 |
+
['None', 'DataPrep', 'SweetViz',]
|
41 |
+
)
|
42 |
+
|
43 |
+
if option3 == 'SweetViz':
|
44 |
+
res = analysis_class.sweetviz_analysis(df)
|
45 |
+
res.show_html(open_browser=True, layout='widescreen', scale=None)
|
46 |
+
|
47 |
+
elif option3 == 'DataPrep':
|
48 |
+
res = analysis_class.dataprep_analysis(df)
|
49 |
+
res.show_browser()
|
50 |
+
|
51 |
+
elif option3 == 'Pandas Profiling':
|
52 |
+
res = analysis_class.pandas_analysis(df)
|
53 |
+
|
54 |
+
|
55 |
model_names = [
|
56 |
"Logistic_Regression",
|
57 |
"Support_Vector_Machine",
|
|
|
67 |
model_names
|
68 |
)
|
69 |
|
70 |
+
model = pickle.load(open(option+'.pkl', 'rb'))
|
71 |
+
|
72 |
st.write("Model Loaded : ", option)
|
73 |
|
74 |
X, y = model_churn.preprocess_inputs(df, option)
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
if option2 == 'Upload custom':
|
77 |
model = model_churn.train(df, model)
|
78 |
|
79 |
+
# st.subheader('This is the Preprocessed Data')
|
80 |
+
|
81 |
+
# st.dataframe(X.head(5))
|
82 |
|
83 |
y_pred = model.predict(X)
|
84 |
|