Chidam Gopal
updates
3b08189 unverified
raw
history blame
760 Bytes
import streamlit as st
import streamlit.components.v1 as components
from infer_intent import IntentClassifier
import matplotlib.pyplot as plt
st.title("Intent classifier")
@st.cache_resource
def get_intent_classifier():
cls = IntentClassifier()
return cls
cls = get_intent_classifier()
query = st.text_input("Enter a query", value="What is the weather today")
pred_result, proba_result = cls.find_intent(query)
st.markdown(f"prediction = :green[{pred_result}]")
keys = list(proba_result.keys())
values = list(proba_result.values())
# Creating the bar plot
fig, ax = plt.subplots()
ax.barh(keys, values)
# Adding labels and title
ax.set_xlabel('probability score')
ax.set_ylabel('Intents')
ax.set_title('Intents probability score')
st.pyplot(fig)