Spaces:
Sleeping
Sleeping
New Update
Browse files
app.py
CHANGED
@@ -16,4 +16,21 @@ scaler = joblib.load('https://drive.google.com/file/d/1qdh31R8f7KzP3UZY9rZkMUrtx
|
|
16 |
lr_model = joblib.load('https://drive.google.com/file/d/1qdh31R8f7KzP3UZY9rZkMUrtxDbX69sr/view?usp=drive_link/lr_smote_model.joblib')
|
17 |
|
18 |
|
|
|
|
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
lr_model = joblib.load('https://drive.google.com/file/d/1qdh31R8f7KzP3UZY9rZkMUrtxDbX69sr/view?usp=drive_link/lr_smote_model.joblib')
|
17 |
|
18 |
|
19 |
+
def preprocess_input(input_data):
|
20 |
+
input_df = pd.DataFrame(input_data, index=[0])
|
21 |
|
22 |
+
cat_columns = [col for col in input_df.columns if input_df[col].dtype == 'object']
|
23 |
+
num_columns = [col for col in input_df.columns if input_df[col].dtype != 'object']
|
24 |
+
|
25 |
+
input_df_imputed_cat = cat_imputer.transform(input_df[cat_columns])
|
26 |
+
input_df_imputed_num = num_imputer.transform(input_df[num_columns])
|
27 |
+
|
28 |
+
input_encoded_df = pd.DataFrame(encoder.transform(input_df_imputed_cat).toarray(),
|
29 |
+
columns=encoder.get_feature_names_out(cat_columns))
|
30 |
+
|
31 |
+
input_df_scaled = scaler.transform(input_df_imputed_num)
|
32 |
+
input_scaled_df = pd.DataFrame(input_df_scaled, columns=num_columns)
|
33 |
+
final_df = pd.concat([input_encoded_df, input_scaled_df], axis=1)
|
34 |
+
final_df = final_df.reindex(columns=original_feature_names, fill_value=0)
|
35 |
+
|
36 |
+
return final_df
|