Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Calculate VIF and filter features with VIF < 10
|
26 |
-
selected_features = calculate_vif(
|
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 =
|
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':
|