Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
be_app.py
CHANGED
|
@@ -1,66 +1,4 @@
|
|
| 1 |
-
# import numpy as np
|
| 2 |
-
# import joblib
|
| 3 |
-
# import pandas as pd
|
| 4 |
-
# from flask import Flask, request, jsonify
|
| 5 |
|
| 6 |
-
# # Initialize the Flask app with a custom name
|
| 7 |
-
# super_kart_predictor_api = Flask("Super Kart Sales Predictor")
|
| 8 |
-
|
| 9 |
-
# # Load the trained model from the specified path
|
| 10 |
-
# # Make sure model_path variable is defined or replace with the actual path string
|
| 11 |
-
# model = joblib.load(model_path)
|
| 12 |
-
|
| 13 |
-
# # Define a route for the home page (GET request)
|
| 14 |
-
# @super_kart_predictor_api.get('/')
|
| 15 |
-
# def home():
|
| 16 |
-
# """
|
| 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 Super Kart Sales Predictor API!"
|
| 21 |
-
|
| 22 |
-
# # Define a route for predictions (POST request)
|
| 23 |
-
# @super_kart_predictor_api.post("/v1/sales")
|
| 24 |
-
# def predict_sales():
|
| 25 |
-
# """
|
| 26 |
-
# This function handles POST requests to the /v1/sales endpoint.
|
| 27 |
-
# It expects a JSON payload containing commodity sales details and returns
|
| 28 |
-
# the predicted sales as a JSON response
|
| 29 |
-
# """
|
| 30 |
-
# # Get JSON data from the POST request
|
| 31 |
-
# superkart_data = request.get_json
|
| 32 |
-
# print(superkart_data)
|
| 33 |
-
|
| 34 |
-
# # Extract relevant features from the JSON payload into a dictionary
|
| 35 |
-
# sample = {
|
| 36 |
-
# 'Product_Weight': superkart_data['Product_Weight'],
|
| 37 |
-
# 'Product_Allocated_Area': superkart_data['Product_Allocated_Area'],
|
| 38 |
-
# 'Product_MRP': superkart_data['Product_MRP'],
|
| 39 |
-
# 'Store_Tenure': superkart_data['Store_Tenure'],
|
| 40 |
-
# 'Product_Category': superkart_data['Product_Category'],
|
| 41 |
-
# 'Product_Sugar_Content': superkart_data['Product_Sugar_Content'],
|
| 42 |
-
# 'Product_Type': superkart_data['Product_Type'],
|
| 43 |
-
# 'Store_Id': superkart_data['Store_Id'],
|
| 44 |
-
# 'Store_Size': superkart_data['Store_Size'],
|
| 45 |
-
# 'Store_Location_City_Type': superkart_data['Store_Location_City_Type'],
|
| 46 |
-
# 'Store_Type': superkart_data['Store_Type'],
|
| 47 |
-
# 'Perishability': superkart_data['Perishability']
|
| 48 |
-
# }
|
| 49 |
-
|
| 50 |
-
# # Create a DataFrame from the input dictionary for model compatibility
|
| 51 |
-
# input_data = pd.DataFrame([sample])
|
| 52 |
-
|
| 53 |
-
# # Predict sales price using the loaded model
|
| 54 |
-
# predicted_sales_price = model.predict(input_data)[0]
|
| 55 |
-
|
| 56 |
-
# # Convert predicted sales price back from log scale using exponential
|
| 57 |
-
# predicted_sales = np.exp(predicted_sales_price)
|
| 58 |
-
|
| 59 |
-
# # Convert the prediction to a float type with rounding to 2 decimal places
|
| 60 |
-
# predicted_sales = float(predicted_sales, 2)
|
| 61 |
-
|
| 62 |
-
# # Return the prediction as a JSON response
|
| 63 |
-
# return jsonify({"predicted_sales_price": predicted_sales})
|
| 64 |
import numpy as np
|
| 65 |
import joblib
|
| 66 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
import joblib
|
| 4 |
import pandas as pd
|