amitcoolll commited on
Commit
b74573b
·
verified ·
1 Parent(s): d851b89

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -26,11 +26,10 @@ def home():
26
  return "HI, Welcome to the Extraa Learn conversion Predictor API!"
27
 
28
  # Define an endpoint for single property prediction (POST request)
29
- @rental_price_predictor_api.post('/v1/conversion')
30
  def predict_rental_price():
31
  property_data = request.get_json()
32
 
33
- # Fix tuple bug by removing commas
34
  sample = {
35
  'age': property_data['age'],
36
  'website_visits': property_data['website_visits'],
@@ -41,16 +40,18 @@ def predict_rental_price():
41
  'profile_completed': property_data['profile_completed'],
42
  'last_activity': property_data['last_activity'],
43
  'print_media_type1': property_data['print_media_type1'],
44
- 'print_media_type2': property_data['print_media_type2'], # ✅ no comma
45
- 'digital_media': property_data['digital_media'], # ✅ no comma
46
  'educational_channels': property_data['educational_channels'],
47
  'referral': property_data['referral']
48
  }
49
 
50
  input_data = pd.DataFrame([sample])
51
- status_log = model.predict(input_data)[0]
52
- status = float(np.exp(status_log))
53
- return jsonify({'Predicted Status': status})
 
 
54
 
55
 
56
  # Define an endpoint for batch prediction (POST request)
 
26
  return "HI, Welcome to the Extraa Learn conversion Predictor API!"
27
 
28
  # Define an endpoint for single property prediction (POST request)
29
+ @@rental_price_predictor_api.post('/v1/conversion')
30
  def predict_rental_price():
31
  property_data = request.get_json()
32
 
 
33
  sample = {
34
  'age': property_data['age'],
35
  'website_visits': property_data['website_visits'],
 
40
  'profile_completed': property_data['profile_completed'],
41
  'last_activity': property_data['last_activity'],
42
  'print_media_type1': property_data['print_media_type1'],
43
+ 'print_media_type2': property_data['print_media_type2'],
44
+ 'digital_media': property_data['digital_media'],
45
  'educational_channels': property_data['educational_channels'],
46
  'referral': property_data['referral']
47
  }
48
 
49
  input_data = pd.DataFrame([sample])
50
+
51
+ # Directly predict class (0 or 1)
52
+ predicted_status = int(model.predict(input_data)[0])
53
+
54
+ return jsonify({'Predicted Status': predicted_status})
55
 
56
 
57
  # Define an endpoint for batch prediction (POST request)