Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -53,7 +53,7 @@ def predict_sales():
|
|
| 53 |
|
| 54 |
# Convert to Python float and round
|
| 55 |
predicted_sales = round(float(predicted_sales), 2)
|
| 56 |
-
|
| 57 |
# Return the actual price
|
| 58 |
return jsonify({'Predicted Sales Forecast (in dollars)': predicted_sales})
|
| 59 |
|
|
@@ -74,17 +74,11 @@ def predict_sales_batch():
|
|
| 74 |
|
| 75 |
# Make predictions for all properties in the DataFrame (get log_prices)
|
| 76 |
predicted_sales = model.predict(input_data).tolist()
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
# predicted_prices = [round(float(np.exp(log_price)), 2) for log_price in predicted_log_prices]
|
| 80 |
-
|
| 81 |
-
# Create a dictionary of predictions with property IDs as keys
|
| 82 |
-
property_ids = input_data['Product_Id'].tolist() # Assuming 'id' is the property ID column
|
| 83 |
-
output_dict = dict(zip(property_ids, predicted_sales)) # Use actual prices
|
| 84 |
-
|
| 85 |
-
# Return the predictions dictionary as a JSON response
|
| 86 |
-
return output_dict
|
| 87 |
|
| 88 |
# Run the Flask application in debug mode if this script is executed directly
|
| 89 |
if __name__ == '__main__':
|
| 90 |
-
|
|
|
|
| 53 |
|
| 54 |
# Convert to Python float and round
|
| 55 |
predicted_sales = round(float(predicted_sales), 2)
|
| 56 |
+
|
| 57 |
# Return the actual price
|
| 58 |
return jsonify({'Predicted Sales Forecast (in dollars)': predicted_sales})
|
| 59 |
|
|
|
|
| 74 |
|
| 75 |
# Make predictions for all properties in the DataFrame (get log_prices)
|
| 76 |
predicted_sales = model.predict(input_data).tolist()
|
| 77 |
+
# Use row indices as keys
|
| 78 |
+
output_dict = {f"Row_{i}": round(float(pred), 2) for i, pred in enumerate(predicted_sales)}
|
| 79 |
|
| 80 |
+
return jsonify(output_dict)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# Run the Flask application in debug mode if this script is executed directly
|
| 83 |
if __name__ == '__main__':
|
| 84 |
+
superkart_sales_forecast_api.run(debug=True)
|