Spaces:
Runtime error
Runtime error
File size: 898 Bytes
619fb86 00dd567 619fb86 6f6379e 619fb86 00dd567 619fb86 00dd567 619fb86 00dd567 0b03db9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
import joblib
vectorizer = joblib.load('./vectorizer.pkl')
nb_classifier = joblib.load('./nb_classifier.pkl')
tfidf_vectorizer = joblib.load('./tfidf_vectorizer.pkl')
random_forest = joblib.load('./random_forest.pkl')
def classify(text,choice):
corpus=[text]
features = vectorizer.transform(corpus).toarray()
if(choice == 1):
prediction = nb_classifier.predict(features)
elif(choice == 2):
prediction = random_forest.predict(features)
if(prediction == 1):
return "Fake News"
else:
return "Not Fake News"
GUI = gr.Interface(inputs = ['text',gr.radio(choices = [('Naive Bayes',1),'(Random Classifier',2)], label = "Model" )], outputs = ['text'], fn = classify, title = "Fake News Detection System")
GUI.launch(debug = True) |