Abubakari commited on
Commit
52179da
1 Parent(s): f56dd67

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -5
main.py CHANGED
@@ -19,11 +19,13 @@ def load_model():
19
  return num_imputer, scaler, model
20
 
21
  def preprocess_input_data(input_data, num_imputer, scaler):
22
- input_data_df = pd.DataFrame(input_data)
23
- num_columns = [col for col in input_data_df.columns if input_data_df[col].dtype != 'object']
24
- input_data_imputed_num = num_imputer.transform(input_data_df[num_columns])
25
- input_scaled_df = pd.DataFrame(scaler.transform(input_data_imputed_num), columns=num_columns)
26
- return input_scaled_df
 
 
27
 
28
  @app.get("/")
29
  def read_root():
 
19
  return num_imputer, scaler, model
20
 
21
  def preprocess_input_data(input_data, num_imputer, scaler):
22
+ input_data_df = pd.DataFrame([input_data], index=[0]) # Add index [0] to the DataFrame
23
+ input_data_scaled = scaler.transform(input_data_df)
24
+ input_data_scaled = pd.DataFrame(input_data_scaled, columns=input_data_df.columns)
25
+ input_data_imputed = num_imputer.transform(input_data_scaled)
26
+
27
+ return input_data_imputed
28
+
29
 
30
  @app.get("/")
31
  def read_root():