Spaces:
Build error
Build error
Download train_model.py from FuurythumbsCPT/Fraud_detection_system_Test: direct link, hf CLI and curl.
- Browser
- Download file 492 Bytes
-
https://huggingface.co/spaces/FuurythumbsCPT/Fraud_detection_system_Test/resolve/main/train_model.py
- Command line
-
hf download hf://spaces/FuurythumbsCPT/Fraud_detection_system_Test/train_model.py
-
curl -L -o train_model.py https://huggingface.co/spaces/FuurythumbsCPT/Fraud_detection_system_Test/resolve/main/train_model.py
492 Bytes
| import pandas as pd | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.ensemble import RandomForestClassifier | |
| import joblib | |
| # Load dataset | |
| df = pd.read_csv("creditcard.csv") | |
| # Features and target | |
| X = df.drop("Class", axis=1) | |
| y = df["Class"] | |
| # Train/test split | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, random_state=42) | |
| # Train model | |
| model = RandomForestClassifier() | |
| model.fit(X_train, y_train) | |
| # Save model | |
| joblib.dump(model, "fraud_model.pkl") |