File size: 1,204 Bytes
b1582cb
 
 
 
b05c932
 
 
 
4d36e92
 
b05c932
b1582cb
b05c932
4d36e92
b05c932
 
 
4d36e92
b05c932
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import altair as alt
import numpy as np
import pandas as pd
import streamlit as st
import streamlit.components.v1 as components
import shap
import pickle
import matplotlib.pyplot as plt
from huggingface_hub import HfFileSystem
fs = HfFileSystem()
#import datetime

arquivos_processados_bb=[]
arquivos_processados_bb.append('spaces/marcossuzuki/TCC_PoliUSPPro/transcrição audio RI/BB/valores_shap-bb1t24.save')

shap_values_bb = []
for path in arquivos_processados_bb:
  with fs.open(path, 'rb') as inp:
    shap_values_bb.append(pickle.load(inp))
    inp.close()

text_num = st.number_input(
    "When do you start?",
    0, max_value = len(shap_values_bb[0])-1
)

option_map = {'POSITIVE':'Positivo', 'NEGATIVE':'Negativo', 'NEUTRAL':'Neutro'}

selection = st.segmented_control(
    "Tool",
    options=option_map.keys(),
    default = 'POSITIVE',
    format_func=lambda option: option_map[option],
    selection_mode="single",
)

shap.initjs()


fig = shap.plots.text(shap_values_bb[0][text_num, :, selection], display = False)

components.html(fig, height=200, scrolling = True)


fig2, ax = plt.subplots()
shap.plots.waterfall(shap_values_bb[0][text_num, :, selection], show=False)
st.pyplot(fig2)