<commit_before>"""Matrix factorization with Sparse PCA."""
# Author: <NAME>, <NAME>, <NAME>
# License: BSD 3 clause

import numpy as np

from ..utils import check_random_state
from ..utils.validation import check_is_fitted
from ..linear_model import ridge_regression
from ..base import BaseEstimator, TransformerMixin
from ._dict_learning import dict_learning, dict_learning_online


class SparsePCA(TransformerMixin, BaseEstimator):
    """Sparse Principal Components Analysis (SparsePCA).

    Finds the set of sparse components that can optimally reconstruct
    the data.  The amount of sparseness is controllable by the coefficient
    of the L1 penalty, given by the parameter alpha.

    Read more in the :ref:`User Guide <SparsePCA>`.

    Parameters
    ----------
    n_components : int, default=None
        Number of sparse atoms to extract.

    alpha : float, default=1
        Sparsity controlling parameter. Higher values lead to sparser<commit_msg>DOC Added the meaning of the default=None case in SparsePCA (#21421)<commit_after>"""Matrix factorization with Sparse PCA."""
# Author: <NAME>, <NAME>, <NAME>
# License: BSD 3 clause

import numpy as np

from ..utils import check_random_state
from ..utils.validation import check_is_fitted
from ..linear_model import ridge_regression
from ..base import BaseEstimator, TransformerMixin
from ._dict_learning import dict_learning, dict_learning_online


class SparsePCA(TransformerMixin, BaseEstimator):
    """Sparse Principal Components Analysis (SparsePCA).

    Finds the set of sparse components that can optimally reconstruct
    the data.  The amount of sparseness is controllable by the coefficient
    of the L1 penalty, given by the parameter alpha.

    Read more in the :ref:`User Guide <SparsePCA>`.

    Parameters
    ----------
    n_components : int, default=None
        Number of sparse atoms to extract. If None, then ``n_components``
        is set to ``n_features_in_``.

    alpha : float, default=1
        Sparsity controlling parameter. Higher values lead to sparser
{'fraction_non_alphanumeric': 0.07692307692307693, 'fraction_numerical': 0.005355404089581304, 'mean_word_length': 3.8696682464454977, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1195976', 'n_tokens_mistral': 588, 'n_tokens_neox': 542, 'n_words': 227}