File size: 1,828 Bytes
3ecaab7
 
a677f92
 
 
 
 
 
 
 
 
 
 
 
 
 
3ecaab7
a677f92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
---

license: mit
language: en
datasets:
- amananandrai/clickbait-dataset
metrics:
- accuracy
tags:
- sklearn
- text-classification
- clickbait
widget:
- text: "You Won't Believe What Happens Next!"
  example_title: "Clickbait Example"
- text: "Scientists Discover New Planet in Solar System"
  example_title: "Non-Clickbait Example"
---


# Clickbait Detection Model (Logistic Regression)

ู‡ุฐุง ู†ู…ูˆุฐุฌ ุชุนู„ู… ุขู„ุฉ (Scikit-learn Pipeline) ุชู… ุชุฏุฑูŠุจู‡ ู„ุชุตู†ูŠู ุนู†ุงูˆูŠู† ุงู„ุฃุฎุจุงุฑ (Headlines) ุฅู„ู‰ "Clickbait" (ุนู†ูˆุงู† ู…ุซูŠุฑ) ุฃูˆ "Not Clickbait" (ุนู†ูˆุงู† ุนุงุฏูŠ).

## ๐Ÿš€ ูƒูŠู ุชุณุชุฎุฏู… ุงู„ู†ู…ูˆุฐุฌ

ุชู… ุญูุธ ุงู„ู†ู…ูˆุฐุฌ ูƒู€ `Pipeline` ูƒุงู…ู„ ู…ู† `sklearn`ุŒ ูˆู‡ูˆ ูŠุชุถู…ู† `TfidfVectorizer` ูˆ `LogisticRegression`. ู‡ุฐุง ูŠุนู†ูŠ ุฃู†ู‡ ูŠุชุนุงู…ู„ ู…ุน ุงู„ู†ุต ู…ุจุงุดุฑุฉ.

```python

import joblib



# ู‚ู… ุจุชุญู…ูŠู„ ุงู„ู†ู…ูˆุฐุฌ ู…ู† Hugging Face Hub

# (ุชุฃูƒุฏ ู…ู† ุชุซุจูŠุช huggingface_hub: pip install huggingface_hub)

from huggingface_hub import hf_hub_download



model_path = hf_hub_download(repo_id="[Ma120]/[clickbait-detector]", filename="clickbait_model.pkl")

model = joblib.load(model_path)



# ุงุฎุชุจุฑ ุงู„ู†ู…ูˆุฐุฌ

headlines = [

    "You Won't Believe What Happens Next!",

    "Local Library Announces Summer Reading Program",

    "10 Signs You're a Genius (Number 7 Will Shock You)",

    "Government Passes New Budget Bill"

]



predictions = model.predict(headlines)



# 1 = Clickbait, 0 = Not Clickbait

for headline, pred in zip(headlines, predictions):

    label = "Clickbait" if pred == 1 else "Not Clickbait"

    print(f"[{label}] {headline}")



# ูŠู…ูƒู†ูƒ ุฃูŠุถุงู‹ ุงู„ุญุตูˆู„ ุนู„ู‰ ุงู„ุงุญุชู…ุงู„ุงุช

# probabilities = model.predict_proba(headlines)

# print(probabilities)