Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import pandas as pd # For data manipulation
|
|
| 5 |
from flask import Flask, request, jsonify # For creating the Flask API
|
| 6 |
|
| 7 |
# Initialize the Flask application
|
| 8 |
-
superkart_sales_forecast_api = Flask("SuperKart Sales Forecast Backend
|
| 9 |
|
| 10 |
# Load the trained machine learning model
|
| 11 |
model = joblib.load("SuperKart_Sales_Forecast_v1_0.joblib")
|
|
@@ -17,7 +17,7 @@ def home():
|
|
| 17 |
This function handles GET requests to the root URL ('/') of the API.
|
| 18 |
It returns a simple welcome message.
|
| 19 |
"""
|
| 20 |
-
return "Welcome to the SuperKart Sales Forecast API
|
| 21 |
|
| 22 |
# Define an endpoint for single property prediction (POST request)
|
| 23 |
@superkart_sales_forecast_api.post('/v1/sales')
|
|
@@ -32,16 +32,18 @@ def predict_sales():
|
|
| 32 |
|
| 33 |
# Extract relevant features from the JSON data
|
| 34 |
sample = {
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# Convert the extracted data into a Pandas DataFrame
|
| 47 |
input_data = pd.DataFrame([sample])
|
|
@@ -87,4 +89,4 @@ def predict_sales_batch():
|
|
| 87 |
|
| 88 |
# Run the Flask application in debug mode if this script is executed directly
|
| 89 |
if __name__ == '__main__':
|
| 90 |
-
|
|
|
|
| 5 |
from flask import Flask, request, jsonify # For creating the Flask API
|
| 6 |
|
| 7 |
# Initialize the Flask application
|
| 8 |
+
superkart_sales_forecast_api = Flask("SuperKart Sales Forecast Backend")
|
| 9 |
|
| 10 |
# Load the trained machine learning model
|
| 11 |
model = joblib.load("SuperKart_Sales_Forecast_v1_0.joblib")
|
|
|
|
| 17 |
This function handles GET requests to the root URL ('/') of the API.
|
| 18 |
It returns a simple welcome message.
|
| 19 |
"""
|
| 20 |
+
return "Welcome to the SuperKart Sales Forecast API!"
|
| 21 |
|
| 22 |
# Define an endpoint for single property prediction (POST request)
|
| 23 |
@superkart_sales_forecast_api.post('/v1/sales')
|
|
|
|
| 32 |
|
| 33 |
# Extract relevant features from the JSON data
|
| 34 |
sample = {
|
| 35 |
+
'Product_Weight': property_data['product_weight'],
|
| 36 |
+
'Product_Sugar_Content': property_data['product_sugar_content'],
|
| 37 |
+
'Product_Allocated_Area': property_data['product_allocated_area'],
|
| 38 |
+
'Product_Type': property_data['product_type'],
|
| 39 |
+
'Product_MRP': property_data['product_mrp'],
|
| 40 |
+
'Store_Establishment_Year': property_data['store_establishment_year'],
|
| 41 |
+
'Store_Size': property_data['store_size'],
|
| 42 |
+
'Store_Location_City_Type': property_data['store_location_city_type'],
|
| 43 |
+
'Store_Type': property_data['store_type']
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
|
| 48 |
# Convert the extracted data into a Pandas DataFrame
|
| 49 |
input_data = pd.DataFrame([sample])
|
|
|
|
| 89 |
|
| 90 |
# Run the Flask application in debug mode if this script is executed directly
|
| 91 |
if __name__ == '__main__':
|
| 92 |
+
rental_price_predictor_api.run(debug=True)
|