CosmickVisions commited on
Commit
4a3a364
Β·
verified Β·
1 Parent(s): 8a5128a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -44,7 +44,12 @@ st.set_page_config(
44
  page_icon="πŸ“ˆ",
45
  initial_sidebar_state="expanded"
46
  )
47
-
 
 
 
 
 
48
  # Security: Set allowed file types
49
  ALLOWED_EXTENSIONS = {'csv', 'xlsx', 'parquet', 'feather'}
50
  MAX_FILE_SIZE_MB = 250 # 250MB limit
@@ -165,6 +170,12 @@ if app_mode == "Data Upload":
165
  st.error(f"Error loading file: {str(e)}")
166
  st.stop()
167
 
 
 
 
 
 
 
168
  # Data Health Dashboard
169
  st.subheader("πŸ“Š Data Health Dashboard")
170
  report = enhanced_quality_report(df)
@@ -752,15 +763,19 @@ elif app_mode == "Model Training":
752
  Choose from a wide range of algorithms and configurations.
753
  """)
754
 
755
- # Initialize session state variables if they don't exist
756
  if 'model' not in st.session_state:
757
  st.session_state.model = None
758
  if 'preprocessor' not in st.session_state:
759
  st.session_state.preprocessor = None
760
-
761
- if 'cleaned_data' not in st.session_state or st.session_state.cleaned_data is None:
762
- st.warning("Please clean your data in the Smart Cleaning section first.")
763
- st.stop()
 
 
 
 
764
 
765
  df = st.session_state.cleaned_data.copy()
766
 
 
44
  page_icon="πŸ“ˆ",
45
  initial_sidebar_state="expanded"
46
  )
47
+ # Initial session state setup (at the top of your script)
48
+ if 'raw_data' not in st.session_state:
49
+ st.session_state.raw_data = None
50
+ if 'cleaned_data' not in st.session_state:
51
+ st.session_state.cleaned_data = None
52
+
53
  # Security: Set allowed file types
54
  ALLOWED_EXTENSIONS = {'csv', 'xlsx', 'parquet', 'feather'}
55
  MAX_FILE_SIZE_MB = 250 # 250MB limit
 
170
  st.error(f"Error loading file: {str(e)}")
171
  st.stop()
172
 
173
+ # In your Data Upload section, add this when new data is uploaded
174
+ if uploaded_file is not None:
175
+ # Reset models when new data is uploaded
176
+ st.session_state.model = None
177
+ st.session_state.preprocessor = None
178
+
179
  # Data Health Dashboard
180
  st.subheader("πŸ“Š Data Health Dashboard")
181
  report = enhanced_quality_report(df)
 
763
  Choose from a wide range of algorithms and configurations.
764
  """)
765
 
766
+ # Initialize session state variables
767
  if 'model' not in st.session_state:
768
  st.session_state.model = None
769
  if 'preprocessor' not in st.session_state:
770
  st.session_state.preprocessor = None
771
+ if 'X_train_selected' not in st.session_state:
772
+ st.session_state.X_train_selected = None
773
+ if 'X_test_selected' not in st.session_state:
774
+ st.session_state.X_test_selected = None
775
+ if 'y_train' not in st.session_state:
776
+ st.session_state.y_train = None
777
+ if 'y_test' not in st.session_state:
778
+ st.session_state.y_test = None
779
 
780
  df = st.session_state.cleaned_data.copy()
781