

.. _example_linear_model_logistic_l1_l2_sparsity.py:


===================
Logistic Regression
===================

Comparison of the sparsity (percentage of zero coefficients) of solutions when
L1 and L2 penalty are used for different values of C. We can see that large
values of C give more freedom to the model.  Conversely, smaller values of C
constrain the model more. In the L1 penalty case, this leads to sparser
solutions.


**Python source code:** :download:`logistic_l1_l2_sparsity.py <logistic_l1_l2_sparsity.py>`

.. literalinclude:: logistic_l1_l2_sparsity.py
    :lines: 12-
    