Download src/train.py from remiXr/test1: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/spaces/remiXr/test1/resolve/main/src/train.py
- Command line
-
hf download hf://spaces/remiXr/test1/src/train.py
-
curl -L -o train.py https://huggingface.co/spaces/remiXr/test1/resolve/main/src/train.py
655 Bytes
| 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") | |