Download scripts/pipeline.py from XRachel/bc4: direct link, hf CLI and curl.
- Browser
- Download file 711 Bytes
-
https://huggingface.co/spaces/XRachel/bc4/resolve/main/scripts/pipeline.py
- Command line
-
hf download hf://spaces/XRachel/bc4/scripts/pipeline.py
-
curl -L -o pipeline.py https://huggingface.co/spaces/XRachel/bc4/resolve/main/scripts/pipeline.py
711 Bytes
| import pandas as pd | |
| from sklearn.linear_model import LogisticRegression | |
| from sklearn.model_selection import train_test_split | |
| import joblib, os | |
| print("===== STEP 1: Load Data =====") | |
| data = pd.DataFrame({ | |
| "Age":[25,45,33,52,23,40,60,48], | |
| "Balance":[1000,5000,2300,8000,1200,4500,9000,3000], | |
| "Exited":[0,1,0,1,0,1,1,0] | |
| }) | |
| print("Dataset ready") | |
| print("===== STEP 2: Train Model =====") | |
| X=data[["Age","Balance"]] | |
| y=data["Exited"] | |
| X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2) | |
| model=LogisticRegression() | |
| model.fit(X_train,y_train) | |
| os.makedirs("models",exist_ok=True) | |
| joblib.dump(model,"models/pipeline.joblib") | |
| print("Model saved to models/pipeline.joblib") | |
| print("Pipeline finished") | |