Applied Lasso Regression in R

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 28

  • @mkzal
    @mkzal 8 місяців тому

    thanks =)
    2:50 epic chewbacca sound

  • @zahiralagheband3520
    @zahiralagheband3520 3 роки тому

    Thanks, Spencer
    It was a great help.
    Absolutely underrated channel

  • @fiacreslokossou2762
    @fiacreslokossou2762 2 роки тому

    thanks spencer

  • @robertasampong
    @robertasampong 2 роки тому

    Thanks, Spencer. Really great explanations.
    Would really appreciate it if you could do a video on "Group LASSO regression" for the "cox" family? (i.e. for time-to-event data)... There's absolutely no video of it out there.

    • @SpencerPaoHere
      @SpencerPaoHere  2 роки тому

      Hmm. Maybe this paper might answer your question?
      www.researchgate.net/figure/The-algorithm-for-Cox-regression-with-group-lasso-penalty_fig2_263498791
      Else, if there is enough interest for cox regression, I could perhaps research further.

  • @annavanhouwelingen5130
    @annavanhouwelingen5130 8 місяців тому

    Great video! I'm encountering some errors with my own data because of the presence of different levels of a categorical predictor in the train vs test dataset. In other words, I have a categorical predictor with different levels which I encoded as dummy variables. However because of the random 80/20 split, my test data does not contain some of the levels which are present in the train data, resulting in an error when using "predict". Do you have any tips on how to go about this? (also in case of z-scoring/ calculating standardized residuals in advance for some variables, I suppose scaling isn't necessary anymore for those variables?). Cheers!

  • @naas6256
    @naas6256 9 місяців тому

    thanks for the explanation, I am wondering if there is any other application with real data that has more features than observation?

    • @SpencerPaoHere
      @SpencerPaoHere  9 місяців тому

      Financial Data, Medical Data, Genomic data -- the list goes on.

  • @liyayaya9503
    @liyayaya9503 2 роки тому

    Anyone knows why the R studio occurred "R Session Aborted and R encountered a fatal error" when I run this line of code???? "ridgeFit

    • @SpencerPaoHere
      @SpencerPaoHere  2 роки тому

      I'd need more info. But, you might be running into a memory allocation issue. You can try to expand your machine by lessesning the restrictions on RAM via R. Else, you probably need a bigger machine or lessen the amount of data you are working with.

  • @IamFermata
    @IamFermata Рік тому

    Hey, Spencer. Great video! For your data, i see that Ridge regression has a smaller value of MSE compared to Lasso. Doesn't that mean that Lasso is a little bit worse than Ridge regression in terms of MSE(though as you said it's not a big difference)?

  • @galan8115
    @galan8115 3 роки тому

    Also, since they are a lot alike, if Lasso have reduced some coefs to 0, it its somewhat more desirable since we can drop variables on the model, right?
    Also, related question. Should you normalize before ridge/lasso?

    • @SpencerPaoHere
      @SpencerPaoHere  3 роки тому

      1) Yes. If the coefficients for lasso reach 0, the algorithm will remove the feature. (One of the beauties of this regularization algorithm)
      2) Yes. You should normalize your data prior to executing ridge/lasso

    • @galan8115
      @galan8115 3 роки тому

      @@SpencerPaoHere Thank you for answering and thank you for your awesome content Spencer :D.

  • @fernandaquiroga3740
    @fernandaquiroga3740 3 роки тому

    From here how do you find which are the most important variables taken by the model or the coefficients from each variable?

    • @SpencerPaoHere
      @SpencerPaoHere  3 роки тому

      The features that are equal to 0 are cancelled out -- thereby leaving you with the remaining features in the dataset. So, now that we know what the primary purpose of Lasso Regression is, we must also know that Lasso Regression does not help you determine which features are "most important".
      You can infer what how effective the model is by doing post-selection inference. Meaning you would test individual features with different weights to see how well the outcome is in comparison with your test data.

  • @rayennenounou7065
    @rayennenounou7065 3 роки тому +1

    Hi i need help i need a application with R for a lasso régression

  • @haticecicek5415
    @haticecicek5415 2 роки тому

    Hi i want to change the lasso constraint how can i do without ready code

    • @SpencerPaoHere
      @SpencerPaoHere  2 роки тому

      Are you talking about the lambda value?
      And, what do you mean without ready code? As in do it from scratch?

  • @TheNiko7980
    @TheNiko7980 2 роки тому

    So when you predict the lasso model, you obtain the fitted values. But how does it work when you forecast out of sample?

    • @SpencerPaoHere
      @SpencerPaoHere  2 роки тому

      When you're forecasting out of sample, you just need the model weights of your trained model. Your out of sample data should follow the same cleaning procedures as your in sample data. Then, you plug in the cleaned out of sample data into your model.

    • @TheNiko7980
      @TheNiko7980 2 роки тому

      @@SpencerPaoHere Ok thanks. When you say model weights, do you mean the beta coefficients of the lasso regression?

    • @SpencerPaoHere
      @SpencerPaoHere  2 роки тому

      @@TheNiko7980 Yes.

    • @TheNiko7980
      @TheNiko7980 2 роки тому

      @@SpencerPaoHere Okay, nice. You’re a lifesaver! How would that look like in R?

    • @SpencerPaoHere
      @SpencerPaoHere  2 роки тому +1

      ​@@TheNiko7980 Something like:
      predict(model, cleaned-out-of-sample-input)