CodingBuddy commited on
Commit
5624573
·
verified ·
1 Parent(s): 97e0dae

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -38,10 +38,17 @@ def predict_churn():
38
  input_data = pd.DataFrame([requestData])
39
 
40
  # create encoder with OneHotEncoder for encoding the selected values to match the training data
41
- encoder = OneHotEncoder(handle_unknown='ignore', sparse_output=False) # Important for handling unseen categories
42
 
43
  # You MUST use the *trained* encoder to transform the new data
44
- encoded_new_data = encoder.transform(input_data[['Product_Sugar_Content','Product_Type','Store_Id','Store_Size','Store_Location_City_Type','Store_Type']])
 
 
 
 
 
 
 
45
 
46
  # Make a churn prediction using the trained model
47
  prediction = model.predict(encoded_new_data).tolist()[0]
 
38
  input_data = pd.DataFrame([requestData])
39
 
40
  # create encoder with OneHotEncoder for encoding the selected values to match the training data
41
+ # encoder = OneHotEncoder(handle_unknown='ignore', sparse_output=False) # Important for handling unseen categories
42
 
43
  # You MUST use the *trained* encoder to transform the new data
44
+ # encoded_new_data = encoder.transform(input_data[['Product_Sugar_Content','Product_Type','Store_Id','Store_Size','Store_Location_City_Type','Store_Type']])
45
+
46
+ encoded_new_data = pd.get_dummies(
47
+ input_data,
48
+ columns=['Product_Sugar_Content','Product_Type','Store_Id','Store_Size','Store_Location_City_Type','Store_Type'],
49
+ drop_first=True,
50
+ );
51
+
52
 
53
  # Make a churn prediction using the trained model
54
  prediction = model.predict(encoded_new_data).tolist()[0]