reading-notes

Code Fellows courses Notes

This project is maintained by QamarAlkhatib

Linear Regressions

How to run Linear regression in Python scikit-Learn

Scikit-learn is a strong Python machine learning tool. Regression, classification, clustering, model selection, and data preprocessing are all functions included. “Methods intended for regression in which the target value is supposed to be a linear combination of the input variables” are found in the sklearn.linear model package.

we can import scikit-learn library As:

import sklearn

from sklearn.linear_model import LinearRegression

Important functions to keep in mind while fitting a linear regression model are:

lm.fit() -> fits a linear model

lm.predict() -> Predict Y using the linear model with estimated coefficients

lm.score() -> Returns the coefficient of determination (R^2). A measure of how well observed outcomes are replicated by the model, as the proportion of total variation of outcomes explained by the model.


Linear Regression in Python