File size: 3,741 Bytes
0da9bd8 2d3d664 0da9bd8 2d49eed 0da9bd8 2d49eed 0da9bd8 a871ecc 0da9bd8 c0ebcc1 0da9bd8 a871ecc 0da9bd8 a871ecc 0da9bd8 a871ecc 0da9bd8 3413844 0da9bd8 a871ecc 3413844 b73b969 e67f338 3413844 0da9bd8 |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
''''
Author : Rupesh Garsondiya
github : @Rupeshgarsondiya
Organization : L.J University
'''
import time
import sys
import streamlit as st
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
from train import *
class test :
def __init__(self):
pass
def predict_data(self):
st.sidebar.title("Select Parameter ")
mt = Model_Train()
S_algo,Pipeline = mt.train_model()
df = None
options = ["Google Pixel 5", "OnePlus 9", "Samsung Galaxy S21", "Xiaomi Mi 11",'iPhone 12']
selected_option = st.sidebar.selectbox("Select phone model :", options)
if selected_option in options:
encoded_model = [1 if i == selected_option else 0 for i in options]
df = pd.DataFrame([encoded_model], columns=options)
options1 = ["Android",'IOS']
if selected_option =='iPhone 12':
selected_option1 = st.sidebar.selectbox("Select OS :", 'IOS')
encoded_os = [0,1]
else :
encoded_os = [1,0]
selected_option1 = st.sidebar.selectbox("Select OS :", 'Android')
df[options1] = encoded_os
options2 = ['Female','Male']
selected_option2 = st.sidebar.radio("Select Gender :", options2)
encoded_gender = [1 if i == selected_option2 else 0 for i in options2]
df[options2] = encoded_gender
app_time = st.sidebar.number_input('Enter total app time (in Hours): ',min_value=0,max_value=24,value=0)
df['App_Time(hours/day)'] = app_time
screen_time = st.sidebar.number_input('Enter your screen time(in hours) : ',min_value=0,max_value=24,value=0)
df['screen_Time(hours/day)'] = screen_time
battary = st.sidebar.number_input('Enter battary drain(mAh) : ',min_value=100,max_value=6000,value=100)
df['Battery_Drain(mAh)'] = battary
no_app = st.sidebar.number_input('Enter number of apps installed : ',min_value=5,max_value=100,value=5)
df['Installed_app'] = no_app
data_use = st.sidebar.number_input('Enter data usage (GB) : ',min_value=0.0,max_value=10.0,value=0.0)
df['Data_Usage(GB)'] = data_use
age = st.sidebar.number_input('Enter your age(in years) : ',min_value=15,max_value=100,value=15)
df['Age'] = age
if st.sidebar.button("Submit"):
for _ in range(3): # Print 'Processing' for 3 seconds
sys.stdout.write("Processing") # Print 'Processing' without a newline
sys.stdout.flush()
time.sleep(1)
sys.stdout.write("\rProcessing.") # Add dot for progress
sys.stdout.flush()
time.sleep(1)
sys.stdout.write("\rProcessing..") # Add second dot for progress
sys.stdout.flush()
time.sleep(1)
sys.stdout.write("\rProcessing...") # Add third dot for progress
sys.stdout.flush()
time.sleep(1)
sys.stdout.write("\r ") # Clear the 'Processing' message
sys.stdout.flush()
prediction = S_algo.predict(df)
if prediction==1:
st.write('Output : Occasional Users')
elif prediction==2:
st.write('Output : Casual Users ')
elif prediction==3:
st.write('Output : content consumer : ')
elif prediction==4:
st.write('Output : Social Media Enthusiasts')
else :
st.write('Output : Power Users') |