How can I use the Lasso to apply to Logistic Regression?
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Cheng-Yu Hsieh
am 29 Aug. 2021
Beantwortet: Kumar Pallav
am 2 Sep. 2021
I am trying to apply supervised binary classification problem with the help of lasso to prevent overfitting. But I am stuck at how to apply lasso to logistic classification function, and how to predict the response values.
Below is the code, where:
- grpTrain_Lasso: a vector of values 1's & 2's, representing 2 categories.
- grpTrain_Lasso_categorical: containing 2 categories: "Cancer", "Normal".
- grpTrain: Original categorical vector, containing the diagnosis of each patient. ("Cancer", "Normal")
- obsSmall: 195x100, where columns are # of patients records, rows are # of features variables.
Lasso Embedded Model Training
[grpTrain_Lasso grpTrain_Lasso_categorical] = grp2idx(grpTrain)
lModel = lasso(obsSmall, grpTrain_Lasso, "CV", 20)
% column: predictor
% row: lambda value for each parameter (for the predictor)
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!