HelloWorld2307 commited on
Commit
c95e38c
·
verified ·
1 Parent(s): 3a79137

Deploy PyCaret model baseline_dt_20250426_212853.pkl

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,11 +1,16 @@
1
 
2
  import streamlit as st
3
  import pandas as pd
 
4
  from pycaret.classification import load_model, predict_model
5
  import os
6
  import warnings # Added to potentially suppress warnings
7
  import logging # Added for better debugging in the Space
8
 
 
 
 
 
9
  # Configure simple logging for the Streamlit app
10
  # Use Streamlit logger if available, otherwise basic config
11
  try:
@@ -17,9 +22,9 @@ except AttributeError: # Fallback for older Streamlit versions or different cont
17
  logger = logging.getLogger(__name__)
18
 
19
 
20
- # --- Configuration ---
21
  MODEL_FILE = "model.pkl" # Relative path within the Space
22
- APP_TITLE = "my-pycaret-app"
23
 
24
  # --- Load Model ---
25
  # Use cache_resource for efficient loading
@@ -55,11 +60,11 @@ def get_model():
55
  logger.exception("Unexpected model loading error details:") # Log full traceback
56
  return None
57
 
 
58
  model = get_model()
59
 
60
  # --- App Layout ---
61
- st.set_page_config(page_title=APP_TITLE, layout="centered")
62
- st.title(APP_TITLE)
63
 
64
  if model is None:
65
  st.error("Model could not be loaded. Please check the application logs in the Space settings for more details. Application cannot proceed.")
 
1
 
2
  import streamlit as st
3
  import pandas as pd
4
+ # Make sure to import the correct module dynamically based on the task
5
  from pycaret.classification import load_model, predict_model
6
  import os
7
  import warnings # Added to potentially suppress warnings
8
  import logging # Added for better debugging in the Space
9
 
10
+ # --- Page Configuration (MUST BE FIRST STREAMLIT COMMAND) ---
11
+ APP_TITLE = "my-pycaret-app"
12
+ st.set_page_config(page_title=APP_TITLE, layout="centered")
13
+
14
  # Configure simple logging for the Streamlit app
15
  # Use Streamlit logger if available, otherwise basic config
16
  try:
 
22
  logger = logging.getLogger(__name__)
23
 
24
 
25
+ # --- Model Configuration ---
26
  MODEL_FILE = "model.pkl" # Relative path within the Space
27
+
28
 
29
  # --- Load Model ---
30
  # Use cache_resource for efficient loading
 
60
  logger.exception("Unexpected model loading error details:") # Log full traceback
61
  return None
62
 
63
+ # --- Load the model ---
64
  model = get_model()
65
 
66
  # --- App Layout ---
67
+ st.title(APP_TITLE) # Title now comes after page config and model loading attempt
 
68
 
69
  if model is None:
70
  st.error("Model could not be loaded. Please check the application logs in the Space settings for more details. Application cannot proceed.")