Spaces:
Runtime error
Runtime error
Commit
·
662ab56
1
Parent(s):
be696f8
Update app.py
Browse files
app.py
CHANGED
@@ -121,35 +121,53 @@ def main():
|
|
121 |
|
122 |
elif app_mode == "Predict Conversion":
|
123 |
st.subheader("Predict Conversion")
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
-
# Check if ML config file was uploaded
|
128 |
-
if mlf_file is not None:
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
|
133 |
-
|
134 |
-
|
135 |
|
136 |
-
|
137 |
-
|
138 |
|
139 |
-
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
|
154 |
if __name__ == "__main__":
|
155 |
main()
|
|
|
121 |
|
122 |
elif app_mode == "Predict Conversion":
|
123 |
st.subheader("Predict Conversion")
|
124 |
+
|
125 |
+
# Create an instance of MarkovChainClassifier with the ML config file
|
126 |
+
model = MarkovChainClassifier("cc.mod")
|
127 |
+
|
128 |
+
# Get user input for userID
|
129 |
+
user_id = st.text_input("Enter User ID")
|
130 |
+
|
131 |
+
# Check if the "Predict" button was clicked
|
132 |
+
if st.button("Predict"):
|
133 |
+
|
134 |
+
# Call the predict method of the MarkovChainClassifier instance
|
135 |
+
pred = model.predict()
|
136 |
+
if pred == 'T':
|
137 |
+
st.write(f"UserID: {user_id}, Prediction: Visitor is likely to convert into a customer.")
|
138 |
+
else:
|
139 |
+
st.write(f"UserID: {user_id}, Prediction: Visitor is unlikely to convert into a customer.")
|
140 |
+
|
141 |
+
# st.subheader("Predict Conversion")
|
142 |
+
# # Upload ML config file using Streamlit's file_uploader function
|
143 |
+
# mlf_file = st.file_uploader("Upload ML config file", type=["properties"])
|
144 |
|
145 |
+
# # Check if ML config file was uploaded
|
146 |
+
# if mlf_file is not None:
|
147 |
+
# # Save the uploaded file to a local file
|
148 |
+
# with open("mcclf_cc.properties", "wb") as f:
|
149 |
+
# f.write(mlf_file.read())
|
150 |
|
151 |
+
# # Create an instance of MarkovChainClassifier with the uploaded ML config file
|
152 |
+
# model = MarkovChainClassifier("mcclf_cc.properties")
|
153 |
|
154 |
+
# # # Load the model from cc.mod
|
155 |
+
# # model = MarkovChainClassifier.load_model("cc.mod")
|
156 |
|
157 |
+
# # Get user input for userID
|
158 |
+
# user_id = st.text_input("Enter User ID")
|
159 |
|
160 |
+
# # Check if the "Predict" button was clicked
|
161 |
+
# if st.button("Predict"):
|
162 |
+
# # Load the saved model
|
163 |
+
# # model.load_model("cc.mod")
|
164 |
|
165 |
+
# # Call the predict method of the MarkovChainClassifier instance
|
166 |
+
# pred = model.predict()
|
167 |
+
# if pred == 'T':
|
168 |
+
# st.write(f"UserID: {user_id}, Prediction: Visitor is likely to convert into a customer.")
|
169 |
+
# else:
|
170 |
+
# st.write(f"UserID: {user_id}, Prediction: Visitor is unlikely to convert into a customer.")
|
171 |
|
172 |
if __name__ == "__main__":
|
173 |
main()
|