LinearRegression in scikit learn

Viewed 195

I have a question regarding the LinearRegression model in scikit learn

(http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html)

If we run the following code:

from sklearn import linear_model
import pandas as pd
import numpy as np

dates   = pd.date_range('20000101', periods=100)
df      = pd.DataFrame(index=dates)
df['A'] = np.cumsum(np.random.randn(100))  
df['B'] = np.cumsum(np.random.randn(100))
df['C'] = np.cumsum(np.random.randn(100))
df['D'] = np.cumsum(np.random.randn(100))  
df['E'] = np.cumsum(np.random.randn(100))
df['F'] = np.cumsum(np.random.randn(100))

y       = ['A','B','C']
x       = ['D','E','F']


ols     = linear_model.LinearRegression(fit_intercept = True, 
                                        normalize     = True, 
                                        copy_X        = True, 
                                        n_jobs        = 1)

ols.fit(df[x],df[y])

What is this ols doing here?

Is it running 3 different OLS regressions? Meaning,

1) an OLS of df['A'] with df[['D','E','F']]

2) an OLS of df['B'] with df[['D','E','F']] and

3) an OLS of df['C'] with df[['D','E','F']]

Or is it running a single OLS of df[['A','B','C']] with df[['D','E','F']] (I think this is called SUR? not sure...)

1 Answers
Related