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

Method inverse_transform

sklearn/preprocessing/_data.py:1137–1179  ·  view source on GitHub ↗

Scale back the data to the original representation. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) The data used to scale along the features axis. copy : bool, default=None Copy the input `X` or not.

(self, X, copy=None)

Source from the content-addressed store, hash-verified

1135 return X
1136
1137 def inverse_transform(self, X, copy=None):
1138 """Scale back the data to the original representation.
1139
1140 Parameters
1141 ----------
1142 X : {array-like, sparse matrix} of shape (n_samples, n_features)
1143 The data used to scale along the features axis.
1144
1145 copy : bool, default=None
1146 Copy the input `X` or not.
1147
1148 Returns
1149 -------
1150 X_original : {ndarray, sparse matrix} of shape (n_samples, n_features)
1151 Transformed array.
1152 """
1153 xp, _, X_device = get_namespace_and_device(X)
1154 check_is_fitted(self)
1155
1156 copy = copy if copy is not None else self.copy
1157 X = check_array(
1158 X,
1159 accept_sparse="csr",
1160 copy=copy,
1161 dtype=supported_float_dtypes(xp, X_device),
1162 force_writeable=True,
1163 ensure_all_finite="allow-nan",
1164 )
1165
1166 if sparse.issparse(X):
1167 if self.with_mean:
1168 raise ValueError(
1169 "Cannot uncenter sparse matrices: pass `with_mean=False` "
1170 "instead See docstring for motivation and alternatives."
1171 )
1172 if self.scale_ is not None:
1173 inplace_column_scale(X, self.scale_)
1174 else:
1175 if self.with_std:
1176 X *= xp.astype(self.scale_, X.dtype)
1177 if self.with_mean:
1178 X += xp.astype(self.mean_, X.dtype)
1179 return X
1180
1181 def __sklearn_tags__(self):
1182 tags = super().__sklearn_tags__()

Calls 5

get_namespace_and_deviceFunction · 0.90
check_is_fittedFunction · 0.90
check_arrayFunction · 0.90
supported_float_dtypesFunction · 0.90
inplace_column_scaleFunction · 0.90