Spaces:
Running
Running
Deploy PyCaret model baseline_dt_20250426_212853.pkl with fixed indentation
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ MODEL_FILE = "model.pkl" # Relative path within the Space
|
|
27 |
|
28 |
# --- Processed Schema (for type checking later) ---
|
29 |
# Use double braces to embed the schema dict correctly in the generated code
|
30 |
-
APP_SCHEMA = {'PassengerId': {'type': 'numerical'}, 'Pclass': {'type': 'numerical'}, 'Name': {'type': 'numerical'}, 'Sex': {'type': '
|
31 |
|
32 |
|
33 |
# --- Load Model ---
|
@@ -83,15 +83,14 @@ else:
|
|
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.
|
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.
|
93 |
-
input_Embarked = st.
|
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 ---
|
@@ -100,7 +99,7 @@ else:
|
|
100 |
try:
|
101 |
# Create DataFrame from inputs using original feature names as keys
|
102 |
# The values are automatically fetched by Streamlit using the keys assigned to widgets
|
103 |
-
input_data_dict = {'PassengerId': input_PassengerId, 'Pclass': input_Pclass, 'Name': input_Name, 'Sex': input_Sex, 'Age': input_Age, 'SibSp': input_SibSp, 'Parch': input_Parch, 'Ticket': input_Ticket, 'Fare': input_Fare, 'Cabin': input_Cabin, 'Embarked': input_Embarked
|
104 |
logger.info(f"Raw input data from form: {input_data_dict}")
|
105 |
input_data = pd.DataFrame([input_data_dict])
|
106 |
|
|
|
27 |
|
28 |
# --- Processed Schema (for type checking later) ---
|
29 |
# Use double braces to embed the schema dict correctly in the generated code
|
30 |
+
APP_SCHEMA = {'PassengerId': {'type': 'numerical'}, 'Pclass': {'type': 'numerical'}, 'Name': {'type': 'numerical'}, 'Sex': {'type': 'categorical', 'values': ['male', 'female']}, 'Age': {'type': 'numerical'}, 'SibSp': {'type': 'numerical'}, 'Parch': {'type': 'numerical'}, 'Ticket': {'type': 'numerical'}, 'Fare': {'type': 'numerical'}, 'Cabin': {'type': 'categorical', 'values': ['A', 'B', 'C']}, 'Embarked': {'type': 'categorical', 'values': ['S', 'C', 'Q']}}
|
31 |
|
32 |
|
33 |
# --- Load Model ---
|
|
|
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.selectbox(label='Sex', options=['male', 'female'], 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.selectbox(label='Cabin', options=['A', 'B', 'C'], key='input_Cabin')
|
93 |
+
input_Embarked = st.selectbox(label='Embarked', options=['S', 'C', 'Q'], key='input_Embarked')
|
|
|
94 |
submitted = st.form_submit_button("π Get Prediction")
|
95 |
|
96 |
# --- Prediction Logic & Output Section ---
|
|
|
99 |
try:
|
100 |
# Create DataFrame from inputs using original feature names as keys
|
101 |
# The values are automatically fetched by Streamlit using the keys assigned to widgets
|
102 |
+
input_data_dict = {'PassengerId': input_PassengerId, 'Pclass': input_Pclass, 'Name': input_Name, 'Sex': input_Sex, 'Age': input_Age, 'SibSp': input_SibSp, 'Parch': input_Parch, 'Ticket': input_Ticket, 'Fare': input_Fare, 'Cabin': input_Cabin, 'Embarked': input_Embarked} # Use triple braces for dict literal inside f-string
|
103 |
logger.info(f"Raw input data from form: {input_data_dict}")
|
104 |
input_data = pd.DataFrame([input_data_dict])
|
105 |
|