aakash200 commited on
Commit
32442a6
·
verified ·
1 Parent(s): c34cc35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -3,10 +3,10 @@ import requests
3
  import pandas as pd
4
 
5
  # App Title
6
- st.title(" Superkart Product Store Sales Prediction")
7
 
8
  # --- Online (Single) Prediction ---
9
- st.subheader(" Online Prediction")
10
 
11
  # Input Fields
12
  store_id = st.number_input("Store ID", min_value=1, step=1, value=1)
@@ -27,37 +27,37 @@ input_data = {
27
  }
28
 
29
  # Predict Button
30
- if st.button(" Predict"):
31
  try:
32
  response = requests.post(
33
- "https://namita2025-superkart-backend.hf.space/predict", # 🔁 Replace with your backend URL if needed
34
  json=input_data
35
  )
36
  if response.status_code == 200:
37
  result = response.json()
38
- st.success(f" Predicted Sales: {result['predicted_sales']} units")
39
  else:
40
- st.error(f" Error from API: Status Code {response.status_code}")
41
  except Exception as e:
42
- st.error(f" Failed to connect to the API. Error: {e}")
43
 
44
  # --- Batch Prediction ---
45
- st.subheader(" Batch Prediction (CSV Upload)")
46
 
47
  file = st.file_uploader("Upload a CSV file with multiple records", type=["csv"])
48
  if file is not None:
49
- if st.button(" Predict Batch"):
50
  try:
51
  response = requests.post(
52
- "https://namita2025-superkart-backend.hf.space/predict_batch", # 🔁 Replace if needed
53
  files={"file": file}
54
  )
55
  if response.status_code == 200:
56
  result = response.json()
57
  df = pd.DataFrame.from_dict(result, orient='index', columns=["Predicted Sales"])
58
- st.success(" Batch Prediction Done!")
59
  st.dataframe(df)
60
  else:
61
- st.error(f" API returned status code {response.status_code}")
62
  except Exception as e:
63
- st.error(f" Failed to perform bat
 
3
  import pandas as pd
4
 
5
  # App Title
6
+ st.title("Superkart Product Store Sales Prediction")
7
 
8
  # --- Online (Single) Prediction ---
9
+ st.subheader("Online Prediction")
10
 
11
  # Input Fields
12
  store_id = st.number_input("Store ID", min_value=1, step=1, value=1)
 
27
  }
28
 
29
  # Predict Button
30
+ if st.button("Predict"):
31
  try:
32
  response = requests.post(
33
+ "https://namita2025-superkart-backend.hf.space/predict", # Replace with your backend URL if needed
34
  json=input_data
35
  )
36
  if response.status_code == 200:
37
  result = response.json()
38
+ st.success(f"Predicted Sales: {result['predicted_sales']} units")
39
  else:
40
+ st.error(f"Error from API: Status Code {response.status_code}")
41
  except Exception as e:
42
+ st.error(f"Failed to connect to the API. Error: {e}")
43
 
44
  # --- Batch Prediction ---
45
+ st.subheader("Batch Prediction (CSV Upload)")
46
 
47
  file = st.file_uploader("Upload a CSV file with multiple records", type=["csv"])
48
  if file is not None:
49
+ if st.button("Predict Batch"):
50
  try:
51
  response = requests.post(
52
+ "https://namita2025-superkart-backend.hf.space/predict_batch", # Replace if needed
53
  files={"file": file}
54
  )
55
  if response.status_code == 200:
56
  result = response.json()
57
  df = pd.DataFrame.from_dict(result, orient='index', columns=["Predicted Sales"])
58
+ st.success("Batch Prediction Done!")
59
  st.dataframe(df)
60
  else:
61
+ st.error(f"API returned status code {response.status_code}")
62
  except Exception as e:
63
+ st.error(f"Failed to perform batch prediction. Error: {e}")