<commit_before>
__version__ = '0.1.0'


__all__ = ['MRMR']


import numpy as np
from sklearn.base import BaseEstimator, MetaEstimatorMixin, clone
from sklearn.utils import check_arrays, safe_mask
from ._mrmr import _mrmr


class MRMR(BaseEstimator, MetaEstimatorMixin):

    def __init__(self, estimator, n_features_to_select=None,
            maxrel=False, mutual_info_difference=True, normalize=False,
            estimator_params={}, verbose=0):

        self.estimator = estimator
        self.n_features_to_select = n_features_to_select
        self.maxrel = maxrel
        self.mutual_info_difference = mutual_info_difference
        self.normalize = normalize
        self.verbose = verbose

    def fit(self, X, y):
        X, y = check_arrays(X, y, sparse_format="csr")
        n_samples, n_features = X.shape
        if self.n_features_to_select is None:
            n_features_to_select = n_features // 2
        else:
            n_features_to_select = self.n_features_to_select

        X_classes = np.array(list(set(X.reshape((n_samples * n_features,)))))
        y_classes = np.array(list(set(y.reshape((n_samples,)))))

        idxs, _, _ = _mrmr(n_samples, n_features, X, y,
                X_classes, y_classes, X_classes.shape[0], y_classes.shape[0],
                n_features_to_select,
                self.maxrel, self.mutual_info_difference, self.normalize)

        support_ = np.zeros(n_features, dtype=np.bool)
        support_[idxs] = True<commit_msg>use proper order for arguments to _mrmr in MRMR(), proper return type, and forgotten estimator params<commit_after>
__version__ = '0.1.0'


__all__ = ['MRMR']


import numpy as np
from sklearn.base import BaseEstimator, MetaEstimatorMixin, clone
from sklearn.utils import check_arrays, safe_mask
from ._mrmr import _mrmr


class MRMR(BaseEstimator, MetaEstimatorMixin):

    def __init__(self, estimator, n_features_to_select=None,
            maxrel=False, mutual_info_difference=True, normalize=False,
            estimator_params={}, verbose=0):

        self.estimator = estimator
        self.n_features_to_select = n_features_to_select
        self.maxrel = maxrel
        self.mutual_info_difference = mutual_info_difference
        self.normalize = normalize
        self.estimator_params = estimator_params
        self.verbose = verbose

    def fit(self, X, y):
        X, y = check_arrays(X, y, sparse_format="csr")
        n_samples, n_features = X.shape
        if self.n_features_to_select is None:
            n_features_to_select = n_features // 2
        else:
            n_features_to_select = self.n_features_to_select

        X_classes = np.array(list(set(X.reshape((n_samples * n_features,)))))
        y_classes = np.array(list(set(y.reshape((n_samples,)))))

        idxs, _ = _mrmr(n_samples, n_features, y, X,
                y_classes, X_classes, y_classes.shape[0], X_classes.shape[0],
                n_features_to_select,
                self.maxrel, self.mutual_info_difference, self.normalize)

        support_ = np.zeros(n_features, dtype=np.bool)
        support_[idxs] = True
{'fraction_non_alphanumeric': 0.09346701164294954, 'fraction_numerical': 0.004527813712807244, 'mean_word_length': 2.970474967907574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6843085', 'n_tokens_mistral': 1057, 'n_tokens_neox': 991, 'n_words': 202}