torch_concepts.data.base.scaler.Scaler¶
- class Scaler(bias=0.0, scale=1.0)[source]¶
Abstract base class for data scaling transformations.
Provides a consistent interface for fitting scalers to data and applying forward/inverse transformations. All concrete scaler implementations should inherit from this class and implement fit(), transform(), and inverse_transform() methods.
- Parameters:
Example
>>> class MinMaxScaler(Scaler): ... def fit(self, x, dim=0): ... self.min = x.min(dim=dim, keepdim=True)[0] ... self.max = x.max(dim=dim, keepdim=True)[0] ... return self ... ... def transform(self, x): ... return (x - self.min) / (self.max - self.min) ... ... def inverse_transform(self, x): ... return x * (self.max - self.min) + self.min
Methods
__init__([bias, scale])fit(x[, dim])Fit the scaler to the input data.
fit_transform(x[, dim])Fit the scaler and transform the input data in one operation.
Reverse the transformation to recover original data.
transform(x)Apply the fitted transformation to the input tensor.