I have a regression problem where I need all coefficents to be positive and the intercept to be zero. I can do this in sklearn but i don't understand how the algoritm can force this conditions through the loss function. Any references will be appreciated.
Lasso does neither of those things. It forces the coefficients of the least important predictors to be zero, but not necessarily the intercept (this would be problem dependent). At the same time, since the loss function contains the absolute value of the coefficients, their sign is irrelevant and only their magnitude has an effect on the result.