Please enable JavaScript.
Coggle requires JavaScript to display documents.
Python - Linear Regression (Metrics (MAE - mean_absolute_error, MSE - mean…
Python - Linear Regression
Data creation
X = dataframe[['CHOSEN COLUMNS, FEATURES']]
y = dataframe['TARGET VARIABLE, VALUE']
Model training
from sklearn.linear_model import LinearRegression
lm = LinearRegression()
lm.fit(X_train, y_train)
Coefficients
lm.coef_
coefficient.example = a 1 unit increase in Avg. Area Income is associated with an increase of $21.52 .
Predicting
predictions = lm.predict(X_test) - predicting X_test data, where y_test are the correct answers
plt.scatter(y_test, predictions) - correctness of the predictions
Metrics
MAE - mean_absolute_error
MSE - mean_squared_error
RMSE - root mean squared error
from sklearn import metrics
Setting the data