Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import numpy as np | |
| import pickle | |
| # Load the trained Random Forest classifier | |
| with open('model.pkl', 'rb') as file: | |
| model = pickle.load(file) | |
| def run_prediction_app(): | |
| st.subheader('Predict Revenue Generation') | |
| # Taking input from the user | |
| Administrative = st.number_input('Administrative', value=0) | |
| Administrative_Duration = st.number_input('Administrative Duration', value=0.0) | |
| Informational = st.number_input('Informational', value=0) | |
| Informational_Duration = st.number_input('Informational Duration', value=0.0) | |
| ProductRelated = st.number_input('ProductRelated', value=0) | |
| ProductRelated_Duration = st.number_input('ProductRelated Duration', value=0.0) | |
| BounceRates = st.number_input('BounceRates', value=0.0) | |
| ExitRates = st.number_input('ExitRates', value=0.0) | |
| PageValues = st.number_input('PageValues', value=0.0) | |
| SpecialDay = st.number_input('SpecialDay', value=0.0) | |
| Month = st.selectbox('Month', ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']) | |
| OperatingSystems = st.number_input('Operating Systems', value=1) | |
| Browser = st.number_input('Browser', value=1) | |
| Region = st.number_input('Region', value=1) | |
| TrafficType = st.number_input('Traffic Type', value=1) | |
| VisitorType = st.selectbox('Visitor Type', ['Returning_Visitor', 'New_Visitor', 'Other']) | |
| Weekend = st.checkbox('Weekend?') | |
| # When 'Predict' is clicked, make the prediction and store it | |
| if st.button('Predict'): | |
| input_data = { | |
| 'Administrative': Administrative, | |
| 'Administrative_Duration': Administrative_Duration, | |
| 'Informational': Informational, | |
| 'Informational_Duration': Informational_Duration, | |
| 'ProductRelated': ProductRelated, | |
| 'ProductRelated_Duration': ProductRelated_Duration, | |
| 'BounceRates': BounceRates, | |
| 'ExitRates': ExitRates, | |
| 'PageValues': PageValues, | |
| 'SpecialDay': SpecialDay, | |
| 'Month': Month, | |
| 'OperatingSystems': OperatingSystems, | |
| 'Browser': Browser, | |
| 'Region': Region, | |
| 'TrafficType': TrafficType, | |
| 'VisitorType': VisitorType, | |
| 'Weekend': Weekend | |
| } | |
| # Make prediction | |
| prediction = model.predict([list(input_data.values())])[0] | |
| st.write(f"Prediction: {'Revenue' if prediction else 'No Revenue'}") | |