File size: 655 Bytes
8a91fa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import joblib
from sklearn.pipeline import Pipeline
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression

# Tiny toy dataset (replace with your own data later)
X = [
    "Win a free iPhone now",
    "Claim your prize urgently",
    "Hey are we still meeting tomorrow?",
    "Can you send me the report by 5?",
    "Limited offer, click here",
    "Lunch at 1pm?",
]
y = [1, 1, 0, 0, 1, 0]  # 1=spam, 0=not spam

model = Pipeline([
    ("tfidf", TfidfVectorizer()),
    ("clf", LogisticRegression(max_iter=1000))
])

model.fit(X, y)

joblib.dump(model, "model.joblib")
print("Saved model.joblib")