File size: 1,911 Bytes
dd38ed4
 
 
 
 
 
 
 
 
 
 
 
 
 
efe6851
dd38ed4
efe6851
 
 
dd38ed4
 
 
 
 
 
 
 
 
 
af4a8bf
 
dd38ed4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import plotly.express as px
from plotly.subplots import make_subplots
from utils import *

########## Title for the Web App ##########
st.title("Text Classification for HC")

########## Create Input field ##########
feedback = st.text_input('Type your text here', 'Customer suggested that the customer service needs to be improved and the response time needs to be improved.')

if st.button('Click for predictions!'):
    with st.spinner('Generating predictions...'):
        
        topics_prob, sentiment_prob, touchpoint_prob = get_single_prediction(feedback)
        
        bar_topic = px.bar(topics_prob, x='probability', y='topic')
        
        bar_touchpoint = px.bar(touchpoint_prob, x='probability', y='touchpoint')
                
        pie = px.pie(sentiment_prob, 
               values='probability', 
               names='sentiment', 
               color_discrete_map={'positive':'rgb(0, 204, 0)', 
                                 'negative':'rgb(215, 11, 11)'
                                  },
               color='sentiment'
              )
        
    st.plotly_chart(bar_topic, use_container_width=True)
    st.plotly_chart(bar_touchpoint, use_container_width=True)
    st.plotly_chart(pie, use_container_width=True)

st.write("\n")    
st.subheader('Or... Upload a csv file if you have a file instead.')
st.write("\n")

st.download_button(
     label="Download sample file here",
     data=sample_file,
     file_name='sample_data.csv',
     mime='text/csv',
 )

uploaded_file = st.file_uploader("Please upload a csv file with only 1 column of texts.")

if uploaded_file is not None:
    
    with st.spinner('Generating predictions...'):
        results = get_multiple_predictions(uploaded_file)
    
    st.download_button(
     label="Download results as CSV",
     data=results,
     file_name='results.csv',
     mime='text/csv',
     )