MCPcopy
hub / github.com/mne-tools/mne-python / fit

Method fit

mne/decoding/transformer.py:86–101  ·  view source on GitHub ↗
(self, X, y=None)

Source from the content-addressed store, hash-verified

84 self._do_scaling = do_scaling
85
86 def fit(self, X, y=None):
87 scalings = _check_scalings_user(self._scalings)
88 picks_by_type = _picks_by_type(
89 pick_info(self._info, _pick_data_channels(self._info, exclude=()))
90 )
91 std = np.ones(sum(len(p[1]) for p in picks_by_type))
92 if X.shape[1] != len(std):
93 raise ValueError(
94 f"info had {len(std)} data channels but X has {len(X)} channels"
95 )
96 if self._do_scaling: # this is silly, but necessary for completeness
97 for kind, picks in picks_by_type:
98 std[picks] = 1.0 / scalings[kind]
99 self.std_ = std
100 self.mean_ = np.zeros_like(std)
101 return self
102
103 def transform(self, X):
104 return X / self.std_

Callers 1

fit_transformMethod · 0.95

Calls 4

_check_scalings_userFunction · 0.85
_picks_by_typeFunction · 0.85
pick_infoFunction · 0.85
_pick_data_channelsFunction · 0.85

Tested by

no test coverage detected