Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,58 @@
|
|
| 1 |
-
import pandas as pd,numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import joblib
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
st.title("User Behavior Using Mobile Prediction")
|
| 6 |
|
| 7 |
-
Device_Model = st.selectbox("Enter Device Model Type",['Xiaomi Mi 11', 'iPhone 12', 'Google Pixel 5',
|
| 8 |
-
age = st.number_input("Enter age",min_value=0,max_value=
|
| 9 |
-
gender = st.radio("Enter gender",['Male','Female'])
|
| 10 |
-
Operating_System= st.selectbox("Enter Operating System Type",['Android','iOS'])
|
| 11 |
App_Usage_Time = st.number_input("Enter the App Usage Time")
|
| 12 |
-
Screen_On_Time= st.number_input("Enter the Screen On Time")
|
| 13 |
-
Battery_Drain= st.number_input("Enter the Battery Drain")
|
| 14 |
Number_of_Apps_Installed = st.number_input("Enter the Number of Apps Installed")
|
| 15 |
Data_Usage = st.number_input("Enter the Data Usage")
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
if st.button("Submit"):
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
# age = st.number_input("Enter age",min_value=0,max_value=1000,step=1,format="%d" )
|
|
|
|
| 1 |
+
# import pandas as pd,numpy as np
|
| 2 |
+
# import joblib
|
| 3 |
+
# import streamlit as st
|
| 4 |
+
|
| 5 |
+
# st.title("User Behavior Using Mobile Prediction")
|
| 6 |
+
|
| 7 |
+
# Device_Model = st.selectbox("Enter Device Model Type",['Xiaomi Mi 11', 'iPhone 12', 'Google Pixel 5','Google Pixel 5','OnePlus 9','Samsung Galaxy S21'])
|
| 8 |
+
# age = st.number_input("Enter age",min_value=0,max_value=1000,step=1,format="%d" )
|
| 9 |
+
# gender = st.radio("Enter gender",['Male','Female'])
|
| 10 |
+
# Operating_System= st.selectbox("Enter Operating System Type",['Android','iOS'])
|
| 11 |
+
# App_Usage_Time = st.number_input("Enter the App Usage Time")
|
| 12 |
+
# Screen_On_Time= st.number_input("Enter the Screen On Time")
|
| 13 |
+
# Battery_Drain= st.number_input("Enter the Battery Drain")
|
| 14 |
+
# Number_of_Apps_Installed = st.number_input("Enter the Number of Apps Installed")
|
| 15 |
+
# Data_Usage = st.number_input("Enter the Data Usage")
|
| 16 |
+
|
| 17 |
+
# model_2 = joblib.load(r"Mobile_data_user_behaviour/rfc.pkl") #pickle file path
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# if st.button("Submit"):
|
| 21 |
+
# result = model_2.predict([[Device_Model,Operating_System,App_Usage_Time,Screen_On_Time,Battery_Drain,Number_of_Apps_Installed,Data_Usage,age,gender]])
|
| 22 |
+
# st.write(f"The predicted price of the rental house is {result}")
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
import pandas as pd
|
| 26 |
+
import numpy as np
|
| 27 |
import joblib
|
| 28 |
import streamlit as st
|
| 29 |
|
| 30 |
st.title("User Behavior Using Mobile Prediction")
|
| 31 |
|
| 32 |
+
Device_Model = st.selectbox("Enter Device Model Type", ['Xiaomi Mi 11', 'iPhone 12', 'Google Pixel 5', 'OnePlus 9', 'Samsung Galaxy S21'])
|
| 33 |
+
age = st.number_input("Enter age", min_value=0, max_value=100, step=1, format="%d")
|
| 34 |
+
gender = st.radio("Enter gender", ['Male', 'Female'])
|
| 35 |
+
Operating_System = st.selectbox("Enter Operating System Type", ['Android', 'iOS'])
|
| 36 |
App_Usage_Time = st.number_input("Enter the App Usage Time")
|
| 37 |
+
Screen_On_Time = st.number_input("Enter the Screen On Time")
|
| 38 |
+
Battery_Drain = st.number_input("Enter the Battery Drain")
|
| 39 |
Number_of_Apps_Installed = st.number_input("Enter the Number of Apps Installed")
|
| 40 |
Data_Usage = st.number_input("Enter the Data Usage")
|
| 41 |
|
| 42 |
+
try:
|
| 43 |
+
model_2 = joblib.load(r"Mobile_data_user_behaviour/rfc.pkl") # Adjust path as needed
|
| 44 |
+
except FileNotFoundError:
|
| 45 |
+
st.error("Model file 'rfc.pkl' not found. Please check the file path.")
|
| 46 |
|
| 47 |
if st.button("Submit"):
|
| 48 |
+
try:
|
| 49 |
+
# Encode categorical features if necessary
|
| 50 |
+
# Assuming you preprocess the data before prediction
|
| 51 |
+
result = model_2.predict([[Device_Model, Operating_System, App_Usage_Time, Screen_On_Time, Battery_Drain, Number_of_Apps_Installed, Data_Usage, age, gender]])
|
| 52 |
+
st.write(f"The predicted price of the rental house is {result}")
|
| 53 |
+
except Exception as e:
|
| 54 |
+
st.error(f"An error occurred during prediction: {e}")
|
| 55 |
+
|
| 56 |
|
| 57 |
|
| 58 |
# age = st.number_input("Enter age",min_value=0,max_value=1000,step=1,format="%d" )
|