Download train_and_save_model.py from mingyk/test-model: direct link, hf CLI and curl.
- Browser
- Download file 472 Bytes
-
https://huggingface.co/mingyk/test-model/resolve/main/train_and_save_model.py
- Command line
-
hf download hf://mingyk/test-model/train_and_save_model.py
-
curl -L -o train_and_save_model.py https://huggingface.co/mingyk/test-model/resolve/main/train_and_save_model.py
472 Bytes
| # train_and_save_model.py | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.datasets import make_regression | |
| import joblib | |
| # Generate example data (replace with your own dataset) | |
| X, y = make_regression(n_samples=100, n_features=3, noise=0.1, random_state=42) | |
| # Train the model | |
| model = LinearRegression() | |
| model.fit(X, y) | |
| # Save the model to a file | |
| joblib.dump(model, "linear_regression_model.joblib") | |
| print("Model saved as 'linear_regression_model.joblib'") | |