MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / inverse_transform

Method inverse_transform

numpy_ml/preprocessing/general.py:244–272  ·  view source on GitHub ↗

Convert a collection of standardized features back into the original feature space. For a standardized sample `z`, the unstandardized score is calculated as: .. math:: x = z s + u where `u` is the mean of the training samples or zero if `with_

(self, Z)

Source from the content-addressed store, hash-verified

242 return (X - self._mean) / self._std
243
244 def inverse_transform(self, Z):
245 """
246 Convert a collection of standardized features back into the original
247 feature space.
248
249 For a standardized sample `z`, the unstandardized score is calculated as:
250
251 .. math::
252
253 x = z s + u
254
255 where `u` is the mean of the training samples or zero if `with_mean` is
256 False, and `s` is the standard deviation of the training samples or 1
257 if `with_std` is False.
258
259 Parameters
260 ----------
261 Z : :py:class:`ndarray <numpy.ndarray>` of shape `(N, C)`
262 An array of `N` standardized samples, each with dimensionality `C`.
263
264 Returns
265 -------
266 X : :py:class:`ndarray <numpy.ndarray>` of shape `(N, C)`
267 The unstandardixed samples from `Z`.
268 """
269 assert self._is_fit, "Must fit `Standardizer` before calling inverse_transform"
270 P = self.parameters
271 mean, std = P["mean"], P["std"]
272 return Z * std + mean
273
274
275class FeatureHasher:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected