File size: 1,308 Bytes
c9f3331
8cdf3cc
 
 
 
 
 
 
 
c9f3331
8cdf3cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
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`:

```python
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}")
```