CoolFace
Apppublic

LongEmptyString/SVM_movie_review_sentiment_classifier

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py26 linesDownload Raw Back to root
1import joblib2import gradio as gr3 4# Load model and vectorizer5clf = joblib.load("sentiment_svm_model.joblib")6vectorizer = joblib.load("tfidf_vectorizer.joblib")7 8# Define prediction function9def predict_sentiment(text):10    X = vectorizer.transform([text])11    pred = clf.predict(X)[0]12    return "๐Ÿ‘ Positive" if pred == 1 else "๐Ÿ‘Ž Negative"13 14# Create Gradio interface15interface = gr.Interface(16    fn=predict_sentiment,17    inputs=gr.Textbox(lines=4, placeholder="Enter a movie review..."),18    outputs="text",19    title="๐ŸŽฌ Sentiment Analyzer (IMDb SVM)",20    description="Enter a movie review. This app predicts whether the sentiment is positive or negative using an SVM classifier trained on IMDb data."21)22 23# Launch the app24if __name__ == "__main__":25    interface.launch()26