TCC_PoliUSPPro / src /streamlit_app.py
marcossuzuki's picture
Modify read origin file method
4d36e92
Raw
History Blame
1.2 kB
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)