Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ def predict(age, workclass, education, marital_status, occupation, relationship,
|
|
17 |
"relationship", "race", "gender", "capital_gain", "capital_loss",
|
18 |
"hours_per_week", "native_country"]
|
19 |
df = pd.DataFrame(index=features, columns=columns)
|
20 |
-
fixed_features = cleaning_features(
|
21 |
# prediction = model.predict(features)
|
22 |
# prediction = 1
|
23 |
# return "Income >50K" if prediction == 1 else "Income <=50K"
|
@@ -63,6 +63,16 @@ def pca(data):
|
|
63 |
data = pd.concat([data, pca_df], axis=1)
|
64 |
return data
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
# Create the Gradio interface
|
68 |
interface = gr.Interface(
|
|
|
17 |
"relationship", "race", "gender", "capital_gain", "capital_loss",
|
18 |
"hours_per_week", "native_country"]
|
19 |
df = pd.DataFrame(index=features, columns=columns)
|
20 |
+
fixed_features = cleaning_features(df)
|
21 |
# prediction = model.predict(features)
|
22 |
# prediction = 1
|
23 |
# return "Income >50K" if prediction == 1 else "Income <=50K"
|
|
|
63 |
data = pd.concat([data, pca_df], axis=1)
|
64 |
return data
|
65 |
|
66 |
+
def hbdscan_tranform(df_transformed):
|
67 |
+
df_transformed['capital-gain'] = np.log1p(df_transformed['capital-gain'])
|
68 |
+
df_transformed['capital-loss'] = np.log1p(df_transformed['capital-loss'])
|
69 |
+
|
70 |
+
# Apply RobustScaler to all numerical features
|
71 |
+
numerical_features = ['age', 'capital-gain', 'capital-loss', 'hours-per-week']
|
72 |
+
scaler = RobustScaler()
|
73 |
+
df_transformed[numerical_features] = scaler.fit_transform(df_transformed[numerical_features])
|
74 |
+
return df_transformed
|
75 |
+
|
76 |
|
77 |
# Create the Gradio interface
|
78 |
interface = gr.Interface(
|