I find that when not fitting intercept (i.e. passing intr=False to glmnet or cvglment), the deviance becomes much larger and often exceeds 1, causing only very few lambdas are searched. Is this a bug? Same issue occurs even after adding 1s column to X to simulate the intercept. Code for reproducing the issue:
import glmnet_python
from glmnet import glmnet; from glmnetPlot import glmnetPlot
from glmnetPrint import glmnetPrint; from glmnetCoef import glmnetCoef; from glmnetPredict import glmnetPredict
from cvglmnet import cvglmnet; from cvglmnetCoef import cvglmnetCoef
from cvglmnetPlot import cvglmnetPlot; from cvglmnetPredict import cvglmnetPredict
import numpy as np
np.random.seed(0)
x = np.random.rand(1000, 10)
w = np.zeros((10, 1))
w[:3]=1
y = np.matmul(x, w) + np.random.rand(1000, 1)
fit = glmnet(x = x.copy(), y = y.copy())
glmnetPrint(fit)
glmnetPlot(fit, xvar = 'lambda', label = True);
# removing the intercept
fit = glmnet(x = x.copy(), y = y.copy(), intr=False)
glmnetPrint(fit)
glmnetPlot(fit, xvar = 'lambda', label = True);
# add 1s column
n = x.shape[0]
x1 = np.concatenate([x, np.ones(shape=(n, 1))], axis=1)
print('x1.shape=',x1.shape)
fit = glmnet(x = x1.copy(), y = y.copy(), intr=False)
glmnetPrint(fit)
glmnetPlot(fit, xvar = 'lambda', label = True);
Hello,
I find that when not fitting intercept (i.e. passing
intr=False
toglmnet
orcvglment
), the deviance becomes much larger and often exceeds 1, causing only very few lambdas are searched. Is this a bug? Same issue occurs even after adding 1s column to X to simulate the intercept. Code for reproducing the issue:Results