# The objection function of Lasso in sklearn: why the coefficient 1/(2*n_samples) is there?

When minimizing squared error, you would often see $$\tfrac{1}{2}$$ there, because derivative of $$\tfrac{1}{2} x^2$$ is $$x$$, while for $$x^2$$ alone it's $$2x$$, so the first expression leads to more "elegant" formulation. As for n_samples, it is to make the loss function an average, so that it doesn't depend on sample size. Both are meant for humans to make reading the code and interpreting results easier, but doesn't matter from optimization point of view, since those are just constants. You can find nice explanation in this thread.