File size: 475 Bytes
26290c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from joblib import load
from sklearn.feature_extraction.text import CountVectorizer, TfidfVectorizer
import pickle


with open('pages/film_review/model/model_logreg_vectorizer.pkl', 'rb') as f:
    vectorizer = pickle.load(f)


# Load the model
classifier = load('pages/film_review/model/model_logreg.joblib')

def predict_tfidf(text):
    text_review_vectorized = vectorizer.transform([text])
    prediction = classifier.predict(text_review_vectorized)
    return prediction