MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / transform

Method transform

sklearn/preprocessing/_data.py:547–586  ·  view source on GitHub ↗

Scale features of X according to feature_range. Parameters ---------- X : array-like of shape (n_samples, n_features) Input data that will be transformed. Returns ------- Xt : ndarray of shape (n_samples, n_features) Transform

(self, X)

Source from the content-addressed store, hash-verified

545 return self
546
547 def transform(self, X):
548 """Scale features of X according to feature_range.
549
550 Parameters
551 ----------
552 X : array-like of shape (n_samples, n_features)
553 Input data that will be transformed.
554
555 Returns
556 -------
557 Xt : ndarray of shape (n_samples, n_features)
558 Transformed data.
559 """
560 check_is_fitted(self)
561
562 xp, _ = get_namespace(X)
563
564 X = validate_data(
565 self,
566 X,
567 copy=self.copy,
568 dtype=_array_api.supported_float_dtypes(xp, device=device(X)),
569 force_writeable=True,
570 ensure_all_finite="allow-nan",
571 reset=False,
572 )
573
574 X *= self.scale_
575 X += self.min_
576 if self.clip:
577 device_ = device(X)
578 X = _modify_in_place_if_numpy(
579 xp,
580 xp.clip,
581 X,
582 xp.asarray(self.feature_range[0], dtype=X.dtype, device=device_),
583 xp.asarray(self.feature_range[1], dtype=X.dtype, device=device_),
584 out=X,
585 )
586 return X
587
588 def inverse_transform(self, X):
589 """Undo the scaling of X according to feature_range.

Calls 5

check_is_fittedFunction · 0.90
get_namespaceFunction · 0.90
validate_dataFunction · 0.90
deviceFunction · 0.90