multiple linear regression example

Example 1: multiple linear regression in python

from sklearn import linear_model
clf = linear_model.LinearRegression()
clf.fit([[getattr(t, 'x%d' % i) for i in range(1, 8)] for t in texts],
        [t.y for t in texts])
#clf.coef_ will have the regression coefficients.

Example 2: Multiple Regression

from sklearn import linear_model
regr = linear_model.LinearRegression()
x = np.asanyarray(train[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB']])
y = np.asanyarray(train[['CO2EMISSIONS']])
regr.fit (x, y)
# The coefficients
print ('Coefficients: ', regr.coef_)

Example 3: plot multiplr linear regression model python

from sklearn import linear_model

ols = linear_model.LinearRegression()
model = ols.fit(X, y)