You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
because then it could be used in combination with FilterEmbedded in mlr3featsel for feature selection in order of L1 inclusion. Importance could be the (approximate) lambda value at which a feature is first included and can easily be calculated from the model.
The text was updated successfully, but these errors were encountered:
Some code I used for something similar (using "old" mlr). This only gets the order by which the features are introduced; I think the approximate lamba value would be more informative.
# orders features by in what order they are introduced when decreasing shrinkage in L1 regression.slfun<-function(task, nselect, alpha=1, ...) {
xy<- getTaskData(task, target.extra=TRUE)
if (getTaskType(task) =="regr") {
family<-"gaussian"
} else {
family<-if (length(levels(xy$target)) >2) "multinomial"else"binomial"
}
fit<- glmnet(x= as.matrix(xy$data), y=xy$target, alpha=alpha,
lambda.min.ratio=1e-4, family=family)
captured<- integer(0)
for (colin seq_len(ncol(fit$beta))) {
curcols<- which(fit$beta[, col] !=0)
newcols<- setdiff(curcols, captured)
captured<- c(captured, newcols)
}
captured<- c(captured, setdiff(seq_len(getTaskNFeats(task)), captured))
res<--order(captured)
names(res) <- getTaskFeatureNames(task)
res
}
@mb706 Like this 7594ad7 ?
Do you know how we can handle multi class tasks? We get for each target class a different beta matrix and the positions at which the features are introduced varies between them.
because then it could be used in combination with FilterEmbedded in mlr3featsel for feature selection in order of L1 inclusion. Importance could be the (approximate) lambda value at which a feature is first included and can easily be calculated from the model.
The text was updated successfully, but these errors were encountered: