Spaces:
Runtime error
Runtime error
Commit History
-
train_spam_model.py
Verified signature# ----------------------------- # 1️⃣ Import des librairies # ----------------------------- import pandas as pd import re import joblib import nltk from nltk.corpus import stopwords from nltk.stem import PorterStemmer from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.model_selection import train_test_split, cross_val_score from sklearn.linear_model import LogisticRegression from sklearn.metrics import classification_report, confusion_matrix, accuracy_score, roc_auc_score from imblearn.over_sampling import SMOTE # Télécharger stopwords si nécessaire nltk.download('stopwords') # ----------------------------- # 2️⃣ Prétraitement des messages # ----------------------------- stop_words = set(stopwords.words('english')) stemmer = PorterStemmer() def preprocess_message(text): if pd.isna(text): return "" text = text.lower() text = re.sub(r'http\S+|www\S+', '', text) # supprimer URLs text = re.sub(r'\S+@\S+', '', text) # suppr…483e6f5