Say I want to fit the following logistic regression model:
$E(y)=(1+e^{-f(X)})^{-1}$
where $f(X) = \beta_0+\beta_1^TX_1 +\beta_2^TX_2 $
and I want to add L1/L2 regularization on $\beta_1$ vector but not $\beta_2$. The reason is that I am doing a causal analysis on the effect of some treatments ($X_2$) on binary $y$ and I am including a large number of control variables ($X_1$) to reduce confounding. I want my estimate on $\beta_2$ to be unbiased, but at the same time, I would be concerned about overfitting if I do not regularize. Hence, I wish to regularize only the control variables.
Is there any way to achieve this in Python?
(Edits: for anyone who had similar problems, I found this answer on StackOverflow to be helpful. TLDR: Try scaling down (e.g., multiply by 0.1) variables you would like to regularize, and then fit a LogisticRegressionCV model. This will increase the scale of coefficient for control variables $X_1$, and hence the model will regularize them much more than the treatment variables $X_2$)