# 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'") | |