Building Linear Regression model
Linear regression is arguably the simplest model that one can build. It is a model of choice if you know that the relationship between your dependent variable and independent ones is linear.
Getting ready
To execute this recipe, you will need pandas
, NumPy
, and Scikit
. No other prerequisites are required.
How to do it…
Estimating the regression model with Scikit
is extremely easy (the regression_linear.py
file):
import sys sys.path.append('..') # the rest of the imports import helper as hlp import pandas as pd import numpy as np import sklearn.linear_model as lm @hlp.timeit def regression_linear(x,y): ''' Estimate a linear regression ''' # create the regressor object linear = lm.LinearRegression(fit_intercept=True, ...
Get Practical Data Analysis Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.