File size: 2,518 Bytes
bb28e0c
cd0223f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f947ad
53b0cd6
cd0223f
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
import pandas as pd
import numpy as np
import requests as requests # Import requests library

st.write("✅ App started - top of script reached")

st.title("Frontend Test OK ✅")

# Streamlit UI for Price Prediction
st.title("SuperKart Revenue Prediction App")
st.write("This tool predicts the Revenue for SuperKart store based on the details.")

st.subheader("Enter the input details:")

# Collect user input
product_weight = st.number_input("Product_Weight", min_value=4.0, max_value=22.0, value=10.0)
product_sugar_content = st.selectbox("Product_Sugar_Content", ["Low Sugar","Regular","No Sugar","reg"])
product_allocated_area = st.number_input("Product_Allocated_Area", min_value=0.0040000, max_value=0.298000, value=0.1)
product_type = st.selectbox("Product_Type", ["Fruits and Vegetables","Snack Foods","Frozen Foods","Dairy","Household","Baking Goods","Canned","Health and Hygiene","Meat","Soft Drinks","Breads","Hard Drinks","Others","Starchy Foods","Breakfast","Seafood"])
product_mrp = st.number_input("Product_MRP", min_value=31.0, max_value=266.0, value=100.0)
store_id = st.selectbox("Store_Id", ["OUT004","OUT001","OUT003","OUT002"])
store_age = st.number_input("Store_Age", min_value=16, max_value=38, value=20)
store_size = st.selectbox("Store_Size", ["Medium","High","Small"])
store_location_city_type = st.selectbox("Store_Location_City_Type", ["Tier 2","Tier 1","Tier 3"])
store_type = st.selectbox("Store_Type", ["Supermarket Type2","Supermarket Type1","Departmental Store","Food Mart"])

# Convert user input into a DataFrame
input_data = pd.DataFrame([{
    'product_weight': product_weight,
    'product_sugar_content': product_sugar_content,
    'product_allocated_area': product_allocated_area,
    'product_type': product_type,
    'product_mrp': product_mrp,
    'store_id': store_id,
    'store_age': store_age,
    'store_size': store_size,
    'store_location_city_type': store_location_city_type,
    'store_type': store_type
}])

st.write("✅ Before API call")

# Make prediction when the "Predict" button is clicked
if st.button("Predict"):
    response = requests.post("https://data2aihub-SuperKartPredictionBackend.hf.space/v1/revenue", json=input_data.to_dict(orient='records')[0])  # Send data to Flask API
    if response.status_code == 200:
        prediction = response.json()['Predicted Revenue (in dollars)']
        st.success(f"Predicted Revenue for this input parameters is : {prediction}")
    else:
        st.error("Error making prediction.")