Rupesh386 commited on
Commit
0da9bd8
·
verified ·
1 Parent(s): 8f18b81

Update test.py

Browse files
Files changed (1) hide show
  1. test.py +93 -0
test.py CHANGED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ''''
2
+ Author : Rupesh Garsondiya
3
+ github : @Rupeshgarsondiya
4
+ Organization : L.J University
5
+ '''
6
+
7
+ import time
8
+ import streamlit as st
9
+ import pandas as pd
10
+ import numpy as np
11
+ from sklearn.preprocessing import StandardScaler
12
+ from train import *
13
+
14
+
15
+ class test :
16
+
17
+ def __init__(self):
18
+ pass
19
+
20
+ def predict_data(self):
21
+
22
+ st.sidebar.title("Select Parameter ")
23
+ mt = Model_Train()
24
+ S_algo,Pipeline = mt.train_model()
25
+ df = None
26
+ options = ["Google Pixel 5", "OnePlus 9", "Samsung Galaxy S21", "Xiaomi Mi 11",'iPhone 12']
27
+
28
+ selected_option = st.sidebar.selectbox("Select phone model :", options)
29
+
30
+ if selected_option in options:
31
+ encoded_model = [1 if i == selected_option else 0 for i in options]
32
+ df = pd.DataFrame([encoded_model], columns=options)
33
+
34
+
35
+
36
+ options1 = ["Android",'IOS']
37
+
38
+
39
+
40
+
41
+ if selected_option =='iPhone 12':
42
+ selected_option1 = st.sidebar.selectbox("Select OS :", 'IOS')
43
+ encoded_os = [0,1]
44
+ else :
45
+ encoded_os = [1,0]
46
+ selected_option1 = st.sidebar.selectbox("Select OS :", 'Android')
47
+ df[options1] = encoded_os
48
+
49
+
50
+ options2 = ['Female','Male']
51
+ selected_option2 = st.sidebar.radio("Select Gender :", options2)
52
+ encoded_gender = [1 if i == selected_option2 else 0 for i in options2]
53
+ df[options2] = encoded_gender
54
+
55
+
56
+ app_time = st.sidebar.number_input('Enter app time : ',min_value=0.0,max_value=24.0,value=0.0)
57
+ df['App_Time(hours/day)'] = app_time
58
+
59
+
60
+ screen_time = st.sidebar.number_input('Enter your screen time : ',min_value=0.0,max_value=24.0,value=0.0)
61
+ df['screen_Time(hours/day)'] = screen_time
62
+
63
+
64
+ battary = st.sidebar.number_input('Enter battary drain(mAh) : ',min_value=100.0,max_value=6000.0,value=100.0)
65
+ df['Battery_Drain(mAh)'] = battary
66
+
67
+
68
+ no_app = st.sidebar.number_input('Enter number of apps installed : ',min_value=5.0,max_value=50.0,value=5.0)
69
+ df['Installed_app'] = no_app
70
+
71
+
72
+ data_use = st.sidebar.number_input('Enter data usage (GB) : ',min_value=0.0,max_value=10.0,value=0.0)
73
+ df['Data_Usage(GB)'] = data_use
74
+
75
+
76
+ age = st.sidebar.number_input('Enter your age : ',min_value=15.0,max_value=100.0,value=15.0)
77
+ df['Age'] = age
78
+
79
+ if st.button("Submit"):
80
+ st.write("Processing...")
81
+ time.sleep(2)
82
+ prediction = S_algo.predict(df)
83
+ if prediction==1:
84
+
85
+ st.write('Output : Occasional Users')
86
+ elif prediction==2:
87
+ st.write('Output : Casual Users ')
88
+ elif prediction==3:
89
+ st.write('Output : content consumer : ')
90
+ elif prediction==4:
91
+ st.write('Output : Social Media Enthusiasts')
92
+ else :
93
+ st.write('Output : Power Users')