What does it mean by fitting a model in Machine Learning?
Learning of a Linear Regression model with introduction of additional data. |
Learning Linear Regression Parameters
Let's take a simple linear regression model of the form: y = ax + b
Here,
- y is the prediction to be made by the model
- x is the input data
- a and b are the parameter.
Code Example
from sklearn import datasets
from sklearn.linear_model import LinearRegression
X_train, y_train = datasets.load_iris(return_X_y=True)
model = LinearRegression()
model.fit(X_train, y_train)
print(f"Model coefficients: {model.coef_}")
print(f"Model intercept: {model.intercept_}")
Output:
Model coefficients: [-0.11190585 -0.04007949 0.22864503 0.60925205]
Model intercept: 0.186495247206249
Post a Comment