Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,36 +5,39 @@ import tensorflow as tf
|
|
5 |
import joblib
|
6 |
|
7 |
# Load trained model
|
8 |
-
model = tf.keras.models.load_model("
|
9 |
|
10 |
# Load encoders and scaler
|
11 |
label_encoders = joblib.load("label_encoders.pkl")
|
12 |
scaler = joblib.load("scaler.pkl")
|
13 |
|
14 |
-
# Define
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
st.title("Classification Prediction App")
|
20 |
|
21 |
# Create input fields for user input
|
22 |
user_input = {}
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
# Convert input to DataFrame
|
31 |
input_df = pd.DataFrame([user_input])
|
32 |
|
33 |
-
# Apply
|
34 |
-
|
35 |
-
input_df[col] = encoder.transform(input_df[col])
|
36 |
-
|
37 |
-
input_df[feature_names] = scaler.transform(input_df[feature_names])
|
38 |
|
39 |
# Predict when user clicks button
|
40 |
if st.button("Predict"):
|
@@ -43,5 +46,6 @@ if st.button("Predict"):
|
|
43 |
st.success(f"Predicted Stage: {predicted_stage}")
|
44 |
|
45 |
|
|
|
46 |
if __name__ == "__main__":
|
47 |
main()
|
|
|
5 |
import joblib
|
6 |
|
7 |
# Load trained model
|
8 |
+
model = tf.keras.models.load_model("baking_model.keras")
|
9 |
|
10 |
# Load encoders and scaler
|
11 |
label_encoders = joblib.load("label_encoders.pkl")
|
12 |
scaler = joblib.load("scaler.pkl")
|
13 |
|
14 |
+
# Define feature names
|
15 |
+
numerical_features = ["DPD", "Credit Expiration"]
|
16 |
+
binary_features = ["Feature1", "Feature2", "Feature3"] # Replace with actual binary features
|
17 |
+
stage_feature = "Stage As Last Month"
|
18 |
|
19 |
st.title("Classification Prediction App")
|
20 |
|
21 |
# Create input fields for user input
|
22 |
user_input = {}
|
23 |
+
|
24 |
+
# Numerical inputs (DPD, Credit Expiration)
|
25 |
+
for feature in numerical_features:
|
26 |
+
user_input[feature] = st.number_input(f"Enter {feature}", value=0, min_value=0)
|
27 |
+
|
28 |
+
# Binary features (Yes/No)
|
29 |
+
for feature in binary_features:
|
30 |
+
user_input[feature] = st.selectbox(f"{feature} (Yes/No)", ["Yes", "No"])
|
31 |
+
user_input[feature] = 1 if user_input[feature] == "Yes" else 0 # Convert to 1/0
|
32 |
+
|
33 |
+
# Stage as Last Month (Dropdown 1, 2, 3)
|
34 |
+
user_input[stage_feature] = st.selectbox("Stage As Last Month", [1, 2, 3])
|
35 |
|
36 |
# Convert input to DataFrame
|
37 |
input_df = pd.DataFrame([user_input])
|
38 |
|
39 |
+
# Apply scaling
|
40 |
+
input_df[numerical_features] = scaler.transform(input_df[numerical_features])
|
|
|
|
|
|
|
41 |
|
42 |
# Predict when user clicks button
|
43 |
if st.button("Predict"):
|
|
|
46 |
st.success(f"Predicted Stage: {predicted_stage}")
|
47 |
|
48 |
|
49 |
+
|
50 |
if __name__ == "__main__":
|
51 |
main()
|