Sentiment_Analyzer / README.md
rejone03's picture
Update README.md
8cdf3cc verified
|
Raw History Blame Contribute Delete
1.31 kB
metadata
language:
  - en
tags:
  - sentiment-analysis
  - text-classification
  - scikit-learn
pipeline_tag: text-classification
library_name: scikit-learn

IMDB Movie Review Sentiment Classifier

This model classifies English movie reviews into Positive or Negative sentiment using TF-IDF and Logistic Regression trained on the 50,000 IMDB dataset.

  • Accuracy: ~90.95%
  • Algorithm: Logistic Regression with TfidfVectorizer (unigrams + bigrams)

How to Use

Download and run predictions with Python using huggingface_hub:

import os
import joblib
from huggingface_hub import hf_hub_download

# Download model and vectorizer from this repository
REPO_ID = "YOUR-USERNAME/imdb-sentiment-analysis"

model_path = hf_hub_download(repo_id=REPO_ID, filename="sentiment_model.pkl")
vectorizer_path = hf_hub_download(repo_id=REPO_ID, filename="tfidf_vectorizer.pkl")

# Load model and vectorizer
model = joblib.load(model_path)
vectorizer = joblib.load(vectorizer_path)

# Test review
reviews = ["This movie was magnificent!", "Terrible waste of time."]
reviews_tfidf = vectorizer.transform(reviews)

predictions = model.predict(reviews_tfidf)

for review, pred in zip(reviews, predictions):
    sentiment = "Positive" if pred == 1 else "Negative"
    print(f"{review} -> {sentiment}")