Upload 6 files
Browse files- .gitattributes +2 -0
- app.py +10 -13
- lgbm_model.pkl +3 -0
- requirements.txt +3 -2
- vectorizer.pkl +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
vectorizer.pkl filter=lfs diff=lfs merge=lfs -text
|
37 |
+
lgbm_model.pkl filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -1,29 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
-
import lightgbm as lgb
|
3 |
import joblib
|
|
|
|
|
4 |
|
5 |
-
# Load your trained model (assuming
|
6 |
model = joblib.load('lgbm_model.pkl')
|
|
|
7 |
|
8 |
def classify_text(text):
|
9 |
-
#
|
10 |
-
|
11 |
-
# processed_text = preprocess_text(text)
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
# features = text_to_features(processed_text)
|
16 |
-
|
17 |
-
# Here, we assume the model can take raw text directly for simplicity
|
18 |
-
prediction = model.predict([text])
|
19 |
|
20 |
return int(prediction[0])
|
21 |
|
22 |
# Create the Gradio interface
|
23 |
iface = gr.Interface(
|
24 |
fn=classify_text,
|
25 |
-
inputs=gr.
|
26 |
-
outputs=gr.
|
27 |
title="Fake News Classifier",
|
28 |
description="Enter text to classify if it's fake (1) or not fake (0).",
|
29 |
examples=["This is a sample news article."]
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import joblib
|
3 |
+
# from lightgbm import LGBMClassifier
|
4 |
+
# from sklearn.feature_extraction.text import TfidfVectorizer
|
5 |
|
6 |
+
# Load your trained model and vectorizer (assuming they're saved as 'lgbm_model.pkl' and 'vectorizer.pkl')
|
7 |
model = joblib.load('lgbm_model.pkl')
|
8 |
+
vectorizer = joblib.load('vectorizer.pkl')
|
9 |
|
10 |
def classify_text(text):
|
11 |
+
# Transform the input text using the loaded vectorizer
|
12 |
+
text_vector = vectorizer.transform([text])
|
|
|
13 |
|
14 |
+
# Predict using the loaded model
|
15 |
+
prediction = model.predict(text_vector)
|
|
|
|
|
|
|
|
|
16 |
|
17 |
return int(prediction[0])
|
18 |
|
19 |
# Create the Gradio interface
|
20 |
iface = gr.Interface(
|
21 |
fn=classify_text,
|
22 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
23 |
+
outputs=gr.Label(),
|
24 |
title="Fake News Classifier",
|
25 |
description="Enter text to classify if it's fake (1) or not fake (0).",
|
26 |
examples=["This is a sample news article."]
|
lgbm_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fe30081cb2fde05af377490a08d9b2ed7bb40c1353f3ae980ac2c5258c4a9320
|
3 |
+
size 2790788
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
-
joblib
|
2 |
-
|
|
|
|
1 |
+
joblib==4.1.0
|
2 |
+
sklearn==1.2.2
|
3 |
+
lightgbm==4.1.0
|
vectorizer.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ffde94fdae46050354244414d5b546e62393226a671057d83da2ccbabda59495
|
3 |
+
size 304927
|