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:
  • bias (float, optional) – Initial bias value. Defaults to 0.0.

  • scale (float, optional) – Initial scale value. Defaults to 1.0.

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
__init__(bias=0.0, scale=1.0)[source]

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.

inverse_transform(x)

Reverse the transformation to recover original data.

transform(x)

Apply the fitted transformation to the input tensor.