import streamlit as st import numpy as np import plotly.express as px def plot_result(top_topics, scores): top_topics = np.array(top_topics) scores = np.array(scores) scores *= 100 fig = px.bar(x=scores, y=top_topics, orientation='h', labels={'x': 'Confidence', 'y': 'Label'}, text=scores, range_x=(0,115), title='Top Predictions', color=np.linspace(0,1,len(scores)), color_continuous_scale='GnBu') fig.update(layout_coloraxis_showscale=False) fig.update_traces(texttemplate='%{text:0.1f}%', textposition='outside') st.plotly_chart(fig)