Spaces:
Running
Running
Deploy PyCaret model baseline_dt_20250426_212853.pkl with fixed indentation
Browse files
app.py
CHANGED
@@ -79,19 +79,19 @@ else:
|
|
79 |
# --- Input Section ---
|
80 |
st.header("Model Inputs")
|
81 |
with st.form("prediction_form"):
|
82 |
-
# Dynamically generated widgets based on schema
|
83 |
input_PassengerId = st.number_input(label='PassengerId', format='%f', key='input_PassengerId')
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
submitted = st.form_submit_button("π Get Prediction")
|
96 |
|
97 |
# --- Prediction Logic & Output Section ---
|
@@ -142,7 +142,8 @@ else:
|
|
142 |
# More robust imputation might be needed depending on the model
|
143 |
# Fill only numerical NaNs with 0, leave others? Or use mode for categoricals?
|
144 |
for feature, details in APP_SCHEMA.items():
|
145 |
-
if
|
|
|
146 |
input_data[feature].fillna(0, inplace=True)
|
147 |
# input_data.fillna(0, inplace=True) # Previous simpler strategy
|
148 |
logger.info(f"Data after filling NaN:\n{input_data}")
|
|
|
79 |
# --- Input Section ---
|
80 |
st.header("Model Inputs")
|
81 |
with st.form("prediction_form"):
|
82 |
+
# Dynamically generated widgets based on schema (now with correct indentation)
|
83 |
input_PassengerId = st.number_input(label='PassengerId', format='%f', key='input_PassengerId')
|
84 |
+
input_Pclass = st.number_input(label='Pclass', format='%f', key='input_Pclass')
|
85 |
+
input_Name = st.number_input(label='Name', format='%f', key='input_Name')
|
86 |
+
input_Sex = st.number_input(label='Sex', format='%f', key='input_Sex')
|
87 |
+
input_Age = st.number_input(label='Age', format='%f', key='input_Age')
|
88 |
+
input_SibSp = st.number_input(label='SibSp', format='%f', key='input_SibSp')
|
89 |
+
input_Parch = st.number_input(label='Parch', format='%f', key='input_Parch')
|
90 |
+
input_Ticket = st.number_input(label='Ticket', format='%f', key='input_Ticket')
|
91 |
+
input_Fare = st.number_input(label='Fare', format='%f', key='input_Fare')
|
92 |
+
input_Cabin = st.number_input(label='Cabin', format='%f', key='input_Cabin')
|
93 |
+
input_Embarked = st.number_input(label='Embarked', format='%f', key='input_Embarked')
|
94 |
+
input_Survived = st.number_input(label='Survived', format='%f', key='input_Survived')
|
95 |
submitted = st.form_submit_button("π Get Prediction")
|
96 |
|
97 |
# --- Prediction Logic & Output Section ---
|
|
|
142 |
# More robust imputation might be needed depending on the model
|
143 |
# Fill only numerical NaNs with 0, leave others? Or use mode for categoricals?
|
144 |
for feature, details in APP_SCHEMA.items():
|
145 |
+
# Check if column exists before attempting to fill
|
146 |
+
if feature in input_data.columns and details.get("type") == "numerical" and input_data[feature].isnull().any():
|
147 |
input_data[feature].fillna(0, inplace=True)
|
148 |
# input_data.fillna(0, inplace=True) # Previous simpler strategy
|
149 |
logger.info(f"Data after filling NaN:\n{input_data}")
|