Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,14 +3,14 @@ import joblib
|
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
|
| 16 |
# def main():
|
|
@@ -120,26 +120,32 @@ family_size = st.number_input("Family Size", min_value=1, max_value=10, value=4,
|
|
| 120 |
pin = st.number_input("Pin", min_value=100000, max_value=999999, value=500000, step=1)
|
| 121 |
|
| 122 |
gender = { "Male" :1,"Female" : 2}
|
| 123 |
-
|
| 124 |
-
|
| 125 |
|
| 126 |
Mirrage = {"Single" : 1, "Married": 2,"Not Revealed" : 3}
|
| 127 |
-
|
|
|
|
|
|
|
| 128 |
|
| 129 |
occupation_dict = {"Student" :1, "Employee" : 2, "Self Employeed" : 3, "House wife" : 4}
|
| 130 |
-
|
|
|
|
| 131 |
|
| 132 |
educational_level = {"Graduate": 1, "Post Graduate":2, "Ph.D":3, "School" :4, "Uneducated" :5}
|
| 133 |
-
|
|
|
|
| 134 |
|
| 135 |
Review_dict = {"Positive" : 1, "Negative":0}
|
| 136 |
-
|
|
|
|
| 137 |
|
| 138 |
|
| 139 |
-
#
|
| 140 |
-
|
| 141 |
-
#
|
| 142 |
-
|
|
|
|
| 143 |
|
| 144 |
-
#
|
| 145 |
-
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
|
| 6 |
+
# load model
|
| 7 |
+
loaded_model = joblib.load('model.pkl')
|
| 8 |
|
| 9 |
|
| 10 |
+
def generate_prediction(input_array):
|
| 11 |
+
ans = loaded_model.predict(input_array)
|
| 12 |
|
| 13 |
+
return ans
|
| 14 |
|
| 15 |
|
| 16 |
# def main():
|
|
|
|
| 120 |
pin = st.number_input("Pin", min_value=100000, max_value=999999, value=500000, step=1)
|
| 121 |
|
| 122 |
gender = { "Male" :1,"Female" : 2}
|
| 123 |
+
Gender_index = st.selectbox("Gender", options=list(gender.keys()))
|
| 124 |
+
Gender = gender[Gender_index]
|
| 125 |
|
| 126 |
Mirrage = {"Single" : 1, "Married": 2,"Not Revealed" : 3}
|
| 127 |
+
Marital_index = st.selectbox("Marital Status", options=list(Mirrage.keys()))
|
| 128 |
+
Marital_status = Mirrage[Marital_index]
|
| 129 |
+
|
| 130 |
|
| 131 |
occupation_dict = {"Student" :1, "Employee" : 2, "Self Employeed" : 3, "House wife" : 4}
|
| 132 |
+
occupation_index = st.selectbox("Marital Status", options=list(occupation_dict.keys()))
|
| 133 |
+
occupation = occupation_dict[occupation_index]
|
| 134 |
|
| 135 |
educational_level = {"Graduate": 1, "Post Graduate":2, "Ph.D":3, "School" :4, "Uneducated" :5}
|
| 136 |
+
educational_index = st.selectbox("educational_level", options=list(educational_level.keys()))
|
| 137 |
+
education = educational_level[educational_index]
|
| 138 |
|
| 139 |
Review_dict = {"Positive" : 1, "Negative":0}
|
| 140 |
+
Review_index = st.multiselect("Review", options=list(Review_dict.keys()))
|
| 141 |
+
Review = Review_dict[Review_index]
|
| 142 |
|
| 143 |
|
| 144 |
+
# Create a button to trigger the model
|
| 145 |
+
if st.button("Predict"):
|
| 146 |
+
# TODO: Replace with your model code
|
| 147 |
+
|
| 148 |
+
prediction = generate_prediction(np.array([[age, income, family_size, pin, Gender, Review, Marital_status, occupation, education]]))
|
| 149 |
|
| 150 |
+
# Show the prediction
|
| 151 |
+
st.write("Prediction:", prediction)
|