OscarKjell / text

Using Transformers from HuggingFace in R
https://r-text.org
132 stars 30 forks source link

regression coefficient #188

Closed zhangdazonggong closed 1 week ago

zhangdazonggong commented 1 month ago

Hey, Thanks for your wonderful package. I found a problem while using the textTrain() function. How can I get the regression coefficient of the model I have trained? Where can I find it?

Thanks for your help.

zhangdazonggong commented 1 month ago

Does the textTrainRegression use ridge regression? If not, does it use Elastic Net? And which variable saves the regression coefficient? Thanks a lot!

OscarKjell commented 1 week ago

Hi, you can set ridge, lasso and elastic net with the mixture parameter:

mixture = A number between 0 and 1 (inclusive) that reflects the proportion of L1 regularization (i.e. lasso) in the model (for more information see the linear_reg-function in the parsnip-package). When mixture = 1, it is a pure lasso model while mixture = 0 indicates that ridge regression is being used (specific engines only).

Training models in the text-package is based on tidymodels. So please look at the "final_model"-object that is outputted when using textTrain(). You can look at the estimates like this:

library(broom) broom::tidy(model_reg$final_model)