Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| import requests | |
| # Set the title of the Streamlit app | |
| st.title("ExtraaLearn System") | |
| # Section for online prediction | |
| st.subheader("Online Prediction") | |
| # Input fields for product and store data | |
| Age = st.number_input("Age", min_value=0, value=25) | |
| Current_Occupation = st.selectbox("Current Occupation", ["Professional", "Student", "Unemployed"]) | |
| First_Interaction = st.selectbox("First Interaction", ["Website", "Mobile App"]) | |
| Profile_Completed = st.selectbox("Profile Completed", ["High", "Medium", "Low"]) | |
| Website_Visits = st.number_input("Website Visits", min_value=0, value=99) | |
| Time_Spent_on_Website = st.number_input("Time Spent on Website") | |
| Page_Views_Per_Visit = st.number_input("Page Views Per Visit", min_value=0.000, value=99.000) | |
| Last_Activity = st.selectbox("Last Activity", ["Website Activity", "Email Activity", "Phone Activity"]) | |
| Print_Media_Type1 = st.selectbox("Print Media Type1", ["Yes", "No"]) | |
| Print_Media_Type2 = st.selectbox("Print Media Type2", ["Yes", "No"]) | |
| Digital_Media = st.selectbox("Digital Media", ["Yes", "No"]) | |
| Educational_Channels = st.selectbox("Educational Channels", ["Yes", "No"]) | |
| Referral = st.selectbox("Referral", ["Yes", "No"]) | |
| # Convert user input into a DataFrame | |
| input_data = pd.DataFrame([{ | |
| "Age": Age, | |
| "Current_Occupation": Current_Occupation, | |
| "First_Interaction": First_Interaction, | |
| "Profile_Completed": Profile_Completed, | |
| "Website_Visits": Website_Visits, | |
| "Time_Spent_on_Website": Time_Spent_on_Website, | |
| "Page_Views_Per_Visit": Page_Views_Per_Visit, | |
| "Last_Activity": Last_Activity, | |
| "Print_Media_Type1": Print_Media_Type1, | |
| "Print_Media_Type2": Print_Media_Type2, | |
| "Digital_Media": Digital_Media, | |
| "Educational_Channels": Educational_Channels, | |
| "Referral": Referral | |
| }]) | |
| # Make prediction when the "Predict" button is clicked | |
| if st.button("Predict"): | |
| response = requests.post("https://vijayendras-ExtraaLearnBacken.hf.space/v1/predict", json=input_data.to_dict(orient='records')[0]) # Send data to Flask API | |
| if response.status_code == 200: | |
| prediction = response.json()['Predicted Sales (in dollars)'] | |
| st.success(f"Predicted Store Sales (in dollars): {prediction}") | |
| else: | |
| st.error("Error making prediction.") | |
| #if st.button("Predict", type='primary'): | |
| # response = requests.post("https://vijayendras-ExtraaLearn-API.hf.space/v1/predict", json=inputt_data) # Replace <user_name> and <space_name> | |
| # if response.status_code == 200: | |
| # result = response.json() | |
| # predicted_sales = result["Sales"] | |
| # st.write(f"Predicted Status: ₹{predicted_sales:.2f}") | |
| # else: | |
| # st.error("Error in API request") | |