0

I performed Lasso regression to first do categorical feature selection (parameter space had 900 features, they were reduced to 78 after Lasso), and then as a linear model to calculate certain response variable. I have the coefficients for the parameters that are important according to Lasso. Any ideas as to how I can convert it to a linear regression equation of the type:

y = β0x0 + β1x1 + β2x2 + ...

Thanks!

ZdaR
  • 22,343
  • 7
  • 66
  • 87
  • Could you use `y = numpy.dot(betas,x)`? Or without numpy `sum(map(operator.mul, betas, x))` (operator needs an import). Or if you want to print it `print(list(zip(betas,x_labels)))`. – Robin Spiess Feb 03 '16 at 15:23
  • The equation I mentioned in the question was an example. The idea is to use regression coefficients (specifically LASSO regression) to write a linear equation. – Shashank Gandhi Feb 06 '16 at 07:20
  • So by writing a linear equation, do you mean to be able to calculate a `y` given an input sample or do you mean to print it out? If you want to calculate it, you can do it by using the dot product as I suggested. `Betas` consists of `[classifier.coef_, classifier.intercept_]` (if you use sklearn) then you create the `x` from `[the given sample, 1]` (the 1 is there to add the intercept) and finally, you can use the dot product to multiply each feature with the corresponding coefficient. This should give a y as you have imagined it. – Robin Spiess Feb 06 '16 at 17:19

0 Answers0