Spencer525 commited on
Commit
a2852d9
·
verified ·
1 Parent(s): 7d695e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -19,17 +19,21 @@ def calculate_vif(df):
19
  # Function to load and process data (including VIF and PCA)
20
  def process_data(file, scaler_option):
21
  df = pd.read_csv(file)
22
- features = ['RI4', 'RI5', 'RI7', 'RI9']
23
- df_selected = df[features].fillna(df.mean())
 
 
 
 
24
 
25
  # Calculate VIF and filter features with VIF < 10
26
- selected_features = calculate_vif(df_selected)
27
-
28
  if not selected_features:
29
  st.error("No features with VIF < 10 found. Please review the data.")
30
- return None
31
 
32
- df_filtered = df[selected_features]
33
 
34
  # Apply chosen scaler
35
  if scaler_option == 'StandardScaler':
 
19
  # Function to load and process data (including VIF and PCA)
20
  def process_data(file, scaler_option):
21
  df = pd.read_csv(file)
22
+
23
+ # Select only numeric columns for VIF calculation
24
+ df_numeric = df.select_dtypes(include=[np.number])
25
+
26
+ # Handle missing values by filling them with the mean of the respective columns
27
+ df_numeric = df_numeric.fillna(df_numeric.mean())
28
 
29
  # Calculate VIF and filter features with VIF < 10
30
+ selected_features = calculate_vif(df_numeric)
31
+
32
  if not selected_features:
33
  st.error("No features with VIF < 10 found. Please review the data.")
34
+ return None, None
35
 
36
+ df_filtered = df_numeric[selected_features]
37
 
38
  # Apply chosen scaler
39
  if scaler_option == 'StandardScaler':