<commit_before>"""Code for Bag-of-SFA Symbols."""

# Author: <NAME> <<EMAIL>>
# License: BSD-3-Clause

import numpy as np
from math import ceil
from scipy.sparse import csr_matrix
from sklearn.base import BaseEstimator
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.utils.validation import check_array, check_is_fitted
from sklearn.utils.multiclass import check_classification_targets
from ..approximation import SymbolicFourierApproximation
from ..base import UnivariateTransformerMixin
from ..utils.utils import _windowed_view


class BOSS(BaseEstimator, UnivariateTransformerMixin):
    """Bag of Symbolic Fourier Approximation Symbols.

    For each time series, subseries are extracted using a slidind window.
    Then the subseries are transformed into a word using the Symbolic
    Fourier Approximation (SFA) algorithm. For each time series, the words
    are grouped together and a histogram counting the occurences of each
    word is created.

    Parameters
    ----------
    word_size : int (default = 4)
        Size of each word.

    n_bins : int (default = 4)
        The number of bins to produce. It must be between 2 and 26.

    strategy : str (default = 'quantile')
        Strategy used to define the widths of the bins:

        - 'uniform': All bins in each sample have identical widths
        - 'quantile': All bins in each sample have the same number of points
        - 'normal': Bin edges are quantiles from a standard normal distribution<commit_msg>Fix typo in BOSS docstring (#127)<commit_after>"""Code for Bag-of-SFA Symbols."""

# Author: <NAME> <<EMAIL>>
# License: BSD-3-Clause

import numpy as np
from math import ceil
from scipy.sparse import csr_matrix
from sklearn.base import BaseEstimator
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.utils.validation import check_array, check_is_fitted
from sklearn.utils.multiclass import check_classification_targets
from ..approximation import SymbolicFourierApproximation
from ..base import UnivariateTransformerMixin
from ..utils.utils import _windowed_view


class BOSS(BaseEstimator, UnivariateTransformerMixin):
    """Bag of Symbolic Fourier Approximation Symbols.

    For each time series, subseries are extracted using a sliding window.
    Then the subseries are transformed into a word using the Symbolic
    Fourier Approximation (SFA) algorithm. For each time series, the words
    are grouped together and a histogram counting the occurences of each
    word is created.

    Parameters
    ----------
    word_size : int (default = 4)
        Size of each word.

    n_bins : int (default = 4)
        The number of bins to produce. It must be between 2 and 26.

    strategy : str (default = 'quantile')
        Strategy used to define the widths of the bins:

        - 'uniform': All bins in each sample have identical widths
        - 'quantile': All bins in each sample have the same number of points
        - 'normal': Bin edges are quantiles from a standard normal distribution
{'fraction_non_alphanumeric': 0.06361239288068557, 'fraction_numerical': 0.004943968358602505, 'mean_word_length': 3.5984848484848486, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1976573', 'n_tokens_mistral': 861, 'n_tokens_neox': 802, 'n_words': 354}