kyled commited on
Commit
0885d54
1 Parent(s): c0b052e

added plotly_chart to frontend

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import transformers as t
3
- import plotly.graph_objects as go
 
4
 
5
  st.title("Phrase Feeling Analysis")
6
  classifier = t.pipeline("zero-shot-classification",
@@ -13,17 +14,8 @@ candidate_labels = ['anger', 'sadness', 'fear', 'joy', 'interest',
13
  output = classifier(x, candidate_labels)
14
  st.write(str(output))
15
 
16
- # fig = go.Figure(data=go.Scatterpolar(
17
- # r=[1, 5, 2, 2, 3],
18
- # theta=candidate_labels,
19
- # fill='toself'
20
- # ))
21
 
22
- # fig.update_layout(
23
- # polar=dict(
24
- # radialaxis=dict(
25
- # visible=True
26
- # ),
27
- # ),
28
- # showlegend=False
29
- # )
 
1
  import streamlit as st
2
  import transformers as t
3
+ import plotly.express as px
4
+ import pandas as pd
5
 
6
  st.title("Phrase Feeling Analysis")
7
  classifier = t.pipeline("zero-shot-classification",
 
14
  output = classifier(x, candidate_labels)
15
  st.write(str(output))
16
 
17
+ df = pd.DataFrame(dict(r=output['scores'], theta=output['labels']))
18
+ fig = px.line_polar(df, r='r', theta='theta', line_close=True)
19
+ fig.update_traces(fill='toself')
 
 
20
 
21
+ st.plotly_chart(fig)