Spaces:
Runtime error
Runtime error
| import numpy as np | |
| import gradio as gr | |
| import joblib | |
| nb_classifier = joblib.load('nb_classifier.pkl') | |
| tfidf_vectorizer = joblib.load('tfidf_vectorizer.pkl') | |
| def predict_sentiment(text): | |
| text_tfidf = tfidf_vectorizer.transform([text]) | |
| predicted_sentiment = nb_classifier.predict(text_tfidf)[0] | |
| return predicted_sentiment | |
| iface = gr.Interface( | |
| fn=predict_sentiment, | |
| inputs="text", | |
| outputs="text", | |
| title="Sentiment Analysis", | |
| description="Predict sentiment of a text message.", | |
| ) | |
| iface.launch(share=True) |