<commit_before># Author: <NAME> <<EMAIL>>
#
# License: BSD (3-clause)

import numpy as np


class RtClassifier:

    """

    Parameters
    ----------

    Attributes
    ----------

    """

    def __init__(self, estimator):

        self.estimator = estimator

    def split_data(self, epochs, Y, tr_percent):
        """Split data into training and test set

        Parameters
        ----------
        epochs :
        Y :
        tr_percent:

        Returns
        -------
        Tr_X:
        Ts_X:
        Tr_Y:
        Ts_Y:

        """

        trnum = round(np.shape(epochs)[0]*tr_percent/100)
        tsnum = np.shape(epochs)[0] - trnum

        Tr_X = np.reshape(epochs[:trnum, :, :],
                          [trnum, np.shape(epochs)[2]*np.shape(epochs)[1]])
        Ts_X = np.reshape(epochs[-tsnum:, :, :],
                          [tsnum, np.shape(epochs)[2]*np.shape(epochs)[1]])
        Tr_Y = Y[:trnum]
        Ts_Y = Y[-tsnum:]

        return Tr_X, Ts_X, Tr_Y, Ts_Y

    def fit(self, X, y):

        self.estimator.fit(X, y)
        return self

    def predict(self, X):

        result = self.estimator.predict(X)

        return result<commit_msg>Modified classifier.py to add the Scaler class which subtracts the mean across channels for each channel type. Fixed PEP8, spaces around operator in epochs.py<commit_after># Author: <NAME> <<EMAIL>>
#
# License: BSD (3-clause)

from sklearn.base import TransformerMixin
from mne.fiff import pick_types


class RtClassifier:

    """
    TODO: complete docstring ...

    Parameters
    ----------

    Attributes
    ----------

    """

    def __init__(self, estimator):

        self.estimator = estimator

    def fit(self, X, y):

        self.estimator.fit(X, y)
        return self

    def predict(self, X):

        result = self.estimator.predict(X)

        return result


class Scaler(TransformerMixin):

    def __init__(self, info):
        self.info = info

    def transform(self, epochs_data):

        picks_list = [pick_types(epochs_data.info, meg='mag', exclude='bads'),
                      pick_types(epochs_data.info, eeg='True', exclude='bads'),
                      pick_types(epochs_data.info, meg='grad', exclude='bads')]

        for pick_one in picks_list:
                ch_mean = epochs_data[:, pick_one, :].mean(axis=1)[:, None, :]
                epochs_data[:, pick_one, :] -= ch_mean

        return epochs_data
{'fraction_non_alphanumeric': 0.14109419991772934, 'fraction_numerical': 0.0053475935828877, 'mean_word_length': 1.8952380952380952, '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': '5599508', 'n_tokens_mistral': 819, 'n_tokens_neox': 780, 'n_words': 176}