-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebsite.py
207 lines (143 loc) · 5.72 KB
/
Website.py
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from PIL import Image
st.sidebar.title("Tesla Customer Satisfaction Analysis from Reddit")
# Using "with" notation
with st.sidebar:
add_radio = st.radio(
"Pages",
("Models Info", "Reddit Comments Analysis", "Sentiment Analysis", "Word Cloud", "Business Recommendations")
)
if (add_radio == 'Models Info'):
st.title('Tesla Models')
col1, col2, col3 = st.columns(3)
with col1:
st.header("Model S")
st.write("Luxury Sedan -- $97k")
st.image("https://i.imgur.com/bOeGXlf.jpeg", width= 400)
with col2:
st.write(" ")
with col3:
st.header("Model 3")
st.write("Affordable Sedan -- $45k")
st.image("https://i.imgur.com/oxo1qMF.jpeg", width= 400)
col1, col2, col3 = st.columns(3)
with col1:
st.header("Model X")
st.write("Luxury SUV -- $107k")
st.image("https://i.imgur.com/lpVEGrH.jpeg", width= 400)
with col2:
st.write(" ")
with col3:
st.header("Model Y")
st.write("Affordable SUV -- $58k")
st.image("https://i.imgur.com/9bzOyOU.jpeg", width= 400)
# with col1:
option = st.selectbox(
'Select for specification details',
('Select here','Model S', 'Model 3', 'Model X', 'Model Y'))
if (option != 'Select here'):
st.write( 'Details for ', option ,':-')
if (option == 'Model S'):
st.write('Range : 396mi')
st.write('0-60 : 1.99s')
st.write('Top Speed : 200mph')
st.write('Peak Power : 1020hp')
if (option == 'Model 3'):
st.write('Range : 358mi')
st.write('0-60 : 3.1s')
st.write('Top Speed : 162mph')
st.write('Peak Power : 450hp')
if (option == 'Model X'):
st.write('Range : 333mi')
st.write('0-60 : 2.5s')
st.write('Top Speed : 163mph')
st.write('Peak Power : 1020hp')
if (option == 'Model Y'):
st.write('Range : 330mi')
st.write('0-60 : 3.5s')
st.write('Top Speed : 155mph')
st.write('Peak Power : 450hp')
st.image("https://imgur.com/Ua0MQoa.jpeg", width= 900)
if (add_radio == 'Reddit Comments Analysis'):
# Set some default options
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', 100)
sns.set_style('darkgrid')
plt.rc('figure', facecolor='#00000000', figsize=(10,8))
plt.rc('font', size=12)
df = pd.read_csv('/Users/abhi/Downloads/TeslaData.csv')
df.drop(columns=['MsgID', 'ThreadID', 'ReplyTo', 'Author'], inplace=True)
df['Timestamp'] = pd.to_datetime(df['Timestamp'], infer_datetime_format=True, format='%Y-%m-%d %H:%M:%S')
# Extract year and month of the data
df['year'] = pd.DatetimeIndex(df['Timestamp']).year
df['month'] = pd.DatetimeIndex(df['Timestamp']).month
st.set_option('deprecation.showPyplotGlobalUse', False)
st.header("Posts and Comments by Year and Month")
st.write(" ")
st.write(" ")
col1, col2 = st.columns(2)
with col1:
# Create a count plot
sns.countplot(x='year', data=df)
plt.title('Number of posts and comments by year')
st.pyplot()
st.write(" ")
st.write(" ")
st.write(" ")
st.write(" ")
with col2:
sns.countplot(x='month', data=df.loc[df['year'] == 2021])
plt.title('Number of posts and comments by month (2021)')
st.pyplot(width = 200)
st.write(" ")
st.write(" ")
st.write(" ")
st.write(" ")
st.write(" ")
st.image("https://imgur.com/E6xs0kK.jpeg", width= 600)
if (add_radio == 'Sentiment Analysis'):
header = st.container()
dataset = st.container()
features = st.container()
model_training = st.container()
# Using object notation
add_selectbox = st.selectbox(
"Choose:",
("Happy Transformer", "Text Blob", "VADER")
)
if(add_selectbox == "Happy Transformer"):
st.title('Sentiment Analysis : Happy Transformer')
st.image("https://imgur.com/b5DfxAV.jpeg", width= 900)
st.write("When manually researching these comments, most of the comments are actually positive or neutral")
if(add_selectbox == "Text Blob"):
st.title('Classifier : Text Blob')
st.write('Model 3 and Model Y have a higher proportion of positive reviews')
st.image("https://imgur.com/GOoYxB0.jpeg", width= 500)
st.image("https://imgur.com/xdVDIuG.jpeg", width= 700)
st.write("It's clear that people don't choose to buy Tesla's luxury SUV models over other models, as the Model X has far fewer reviews than other models")
if(add_selectbox == "VADER"):
st.title('Sentiment Analysis : VADER')
st.image("https://imgur.com/1w56srM.jpeg", width= 900)
st.write("Autopilot and after-sales service are representative features of Tesla, and based on VADER sentiment analysis, the responses are truly great")
if (add_radio == 'Word Cloud'):
add_selectbox = st.selectbox(
"Choose:",
("Overall Comments","Positive Reviews contain 'AUTOPILOT'","Comments contain 'SERVICE'"))
if(add_selectbox == "Overall Comments"):
st.image("https://imgur.com/nNL2pG9.jpeg", width= 900)
if(add_selectbox == "Positive Reviews contain 'AUTOPILOT'"):
st.image("https://imgur.com/mSNpbu2.jpeg", width= 900)
if(add_selectbox == "Comments contain 'SERVICE'"):
st.image("https://imgur.com/t2zZ5oH.jpeg", width= 900)
if (add_radio == 'Business Recommendations'):
st.title("Business Recommendations")
st.subheader("Target Model")
st.write("In general, Model 3 is indeed a relatively painless starting model, with the most basic equipment but the highest cost - performance ratio")
st.subheader("Features focusing")
st.write("Having a high percentage of praise fully reflects Tesla‘s success in autopilot, and Tesla should continue to be at the forefront of this field")
st.subheader("Price & Policy")
st.write("Price is subjective, but good after-sales service can increase customer loyalty, or occasionally going crazy like sending a lifetime supercharger")