kapilmika commited on
Commit
2f9f63c
·
verified ·
1 Parent(s): d527ba7

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +2 -13
app.py CHANGED
@@ -46,19 +46,14 @@ def predict_product_revenue_price():
46
 
47
  # Convert the extracted data into a Pandas DataFrame
48
  input_data = pd.DataFrame([sample])
49
- print("input_data:", input_data)
50
 
51
  # Make prediction (get log_price)
52
  predicted_log_price = model.predict(input_data)[0]
53
- print("predicted_log_price:", predicted_log_price)
54
  # Calculate actual price
55
- # predicted_price = np.exp(predicted_log_price)
56
  predicted_price = predicted_log_price
57
- print("predicted_price:", predicted_price)
58
 
59
  # Convert predicted_price to Python float
60
- predicted_price = round(float(predicted_price), 2)
61
- print("predicted_price:", predicted_price)
62
  # The conversion above is needed as we convert the model prediction (log price) to actual price using np.exp, which returns predictions as NumPy float32 values.
63
  # When we send this value directly within a JSON response, Flask's jsonify function encounters a datatype error
64
 
@@ -82,18 +77,12 @@ def predict_product_revenue_price_batch():
82
 
83
  # Make predictions for all properties in the DataFrame (get log_prices)
84
  predicted_log_prices = model.predict(input_data).tolist()
85
- print("input_data:", input_data)
86
- print("predicted_log_prices:", predicted_log_prices)
87
 
88
  # Calculate actual prices
89
- # predicted_prices = [round(float(np.exp(log_price)), 2) for log_price in predicted_log_prices]
90
- predicted_prices = [round(float(log_price), 2) for log_price in predicted_log_prices]
91
-
92
- print("predicted_prices:", predicted_prices)
93
 
94
  # Create a dictionary of predictions with property IDs as keys
95
  property_ids = input_data['Product_Id'].tolist() # Assuming 'id' is the property ID column
96
- print("property_ids:", property_ids)
97
 
98
  output_dict = dict(zip(property_ids, predicted_prices)) # Use actual prices
99
 
 
46
 
47
  # Convert the extracted data into a Pandas DataFrame
48
  input_data = pd.DataFrame([sample])
 
49
 
50
  # Make prediction (get log_price)
51
  predicted_log_price = model.predict(input_data)[0]
 
52
  # Calculate actual price
 
53
  predicted_price = predicted_log_price
 
54
 
55
  # Convert predicted_price to Python float
56
+ predicted_price = round(float(predicted_price), 6)
 
57
  # The conversion above is needed as we convert the model prediction (log price) to actual price using np.exp, which returns predictions as NumPy float32 values.
58
  # When we send this value directly within a JSON response, Flask's jsonify function encounters a datatype error
59
 
 
77
 
78
  # Make predictions for all properties in the DataFrame (get log_prices)
79
  predicted_log_prices = model.predict(input_data).tolist()
 
 
80
 
81
  # Calculate actual prices
82
+ predicted_prices = [round(float(log_price), 6) for log_price in predicted_log_prices]
 
 
 
83
 
84
  # Create a dictionary of predictions with property IDs as keys
85
  property_ids = input_data['Product_Id'].tolist() # Assuming 'id' is the property ID column
 
86
 
87
  output_dict = dict(zip(property_ids, predicted_prices)) # Use actual prices
88