File size: 472 Bytes
9d2ec8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 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'")