Suppose I have already chosen a penalization parameter lambda, and I want to fit trac() on a dataset with only that value of lambda .
This situation arises if I want to perform the cross-validation for selection of regularization parameter lambda outside of trac(), for instance.
Let's suppose I want to use lambda = 0.15. Following the vignette, the following attempt causes an error in c-lasso:
# from the vignette:
library(trac)
names(sCD14)
set.seed(123)
ntot <- length(sCD14$y)
n <- round(2/3 * ntot)
tr <- sample(ntot, n)
log_pseudo <- function(x, pseudo_count = 1) log(x + pseudo_count)
ytr <- sCD14$y[tr]
yte <- sCD14$y[-tr]
ztr <- log_pseudo(sCD14$x[tr, ])
zte <- log_pseudo(sCD14$x[-tr, ])
# use fraclist to select a single value for lambda.
fit <- trac(ztr, ytr, A = sCD14$A, fraclist = 0.15 ) # lambda = 0.15 is my favorite.
The error message is:
Error in py_call_impl(callable, dots$args, dots$keywords) :
TypeError: 'float' object is not subscriptable
Detailed traceback:
File "/data1/packages/python_3.8_venv_20210618/lib/python3.8/site-packages/classo/solver.py", line 133, in solve
self.solution.PATH = solution_PATH(
File "/data1/packages/python_3.8_venv_20210618/lib/python3.8/site-packages/classo/solver.py", line 845, in __init__
out = pathlasso(
File "/data1/packages/python_3.8_venv_20210618/lib/python3.8/site-packages/classo/compact_func.py", line 208, in pathlasso
if lambdas[0] < lambdas[-1]:
It looks like it fails because c-lasso requires at least two values of lambda in order to work.
In support of that hypothesis, the same error message is returned if I try to execute trac() as in the vignette but restricting nlam=1:
fit <- trac(ztr, ytr, A = sCD14$A, min_frac = 1e-2, nlam = 1)
Suppose I have already chosen a penalization parameter lambda, and I want to fit
trac()on a dataset with only that value oflambda.This situation arises if I want to perform the cross-validation for selection of regularization parameter
lambdaoutside oftrac(), for instance.Let's suppose I want to use
lambda = 0.15. Following the vignette, the following attempt causes an error inc-lasso:The error message is:
It looks like it fails because
c-lassorequires at least two values oflambdain order to work.In support of that hypothesis, the same error message is returned if I try to execute
trac()as in the vignette but restrictingnlam=1: