Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from sklearn.feature_extraction.text import CountVectorizer
|
|
|
3 |
import joblib
|
4 |
|
5 |
vectorizer = joblib.load('./vectorizer.pkl')
|
6 |
nb_classifier = joblib.load('./nb_classifier.pkl')
|
7 |
-
|
|
|
|
|
|
|
8 |
corpus=[text]
|
9 |
-
features = vectorizer.transform(corpus)
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
if(prediction == 1):
|
13 |
return "Fake News"
|
14 |
else:
|
15 |
return "Not Fake News"
|
16 |
|
17 |
-
GUI = gr.Interface(inputs = ['text'], outputs = ['text'], fn = classify, title = "Fake News Detection System")
|
18 |
GUI.launch(debug = True)
|
|
|
1 |
import gradio as gr
|
2 |
from sklearn.feature_extraction.text import CountVectorizer
|
3 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
4 |
import joblib
|
5 |
|
6 |
vectorizer = joblib.load('./vectorizer.pkl')
|
7 |
nb_classifier = joblib.load('./nb_classifier.pkl')
|
8 |
+
tfidf_vectorizer = joblib.load('./tfidf_vectorizer.pkl')
|
9 |
+
random_forest = joblib.load('./random_forest.pkl')
|
10 |
+
|
11 |
+
def classify(text,choice):
|
12 |
corpus=[text]
|
13 |
+
features = vectorizer.transform(corpus).toarray()
|
14 |
+
if(choice == 1):
|
15 |
+
prediction = nb_classifier.predict(features)
|
16 |
+
elif(choice == 2):
|
17 |
+
prediction = random_forest.predict(features)
|
18 |
if(prediction == 1):
|
19 |
return "Fake News"
|
20 |
else:
|
21 |
return "Not Fake News"
|
22 |
|
23 |
+
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")
|
24 |
GUI.launch(debug = True)
|