1

I have the following linear model

regressor = LinearRegression()
regressor.fit(X_train, y_train)

y_pred = regressor.predict(X_test)

Then, I create a coefficient-feature table by doing:

# List of features
features = list(dataset2.iloc[:, 0:-1].columns)

# List of coefficients
coefficients = regressor.coef_
coefficients = list(coefficients)

data = {"Features": features,
       "Coefficients": coefficients}

coeff_table = pd.DataFrame(data)
coeff_table


>>
Features           Coefficients
0   x1             -6.355051e-07
1   x1              2.155908e-06
2   x3              3.747445e-04
3   x4             -2.002543e-05
4   x5              7.554939e-06
5   x6              7.073696e-06
6   x7              3.017401e-04
7   x8              3.173331e-03
8   x9              3.513537e-04
9   x10             3.232741e-05

I would like to also compute the standard error and add it to my table. I am wondering what the best approach to do it is. I keep either finding answers too long or not suitable for my model (they use OLS()).

9769953
  • 10,344
  • 3
  • 26
  • 37
Joehat
  • 979
  • 1
  • 9
  • 36
  • 1
    you need the variance - covariance matrix and this is not returned by sklearn. see https://stats.stackexchange.com/questions/216335/standard-error-for-a-parameter-in-ordinary-least-squares and https://stackoverflow.com/questions/22381497/python-scikit-learn-linear-model-parameter-standard-error – StupidWolf Aug 14 '21 at 04:20

0 Answers0