Preprocessing¶
dicex.preprocessing.scaling.DicexScaler() ¶
Standardization (z-score) of the features used by Dicex.
The optimizer searches and perturbs in standardized units; the scaler wraps the model so that it receives the original units, and maps the resulting direction back to the original feature space.
Attributes:
| Name | Type | Description |
|---|---|---|
mean_ | ndarray | None | Mean of each feature, set by |
std_ | ndarray | None | Standard deviation of each feature, set by |
Source code in src/dicex/preprocessing/scaling.py
fit(x) ¶
Learn mean and std from data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | ndarray | Input data array of shape (n_samples, n_features). | required |
Returns:
| Name | Type | Description |
|---|---|---|
DicexScaler | DicexScaler | The fitted scaler instance (self). |
Source code in src/dicex/preprocessing/scaling.py
inverse_transform(x_scaled) ¶
Invert the scaling transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_scaled | ndarray | Scaled data array. | required |
Returns:
| Type | Description |
|---|---|
ndarray | np.ndarray: The data array in the original space. |
Source code in src/dicex/preprocessing/scaling.py
transform(x) ¶
Scale data to zero mean and unit variance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | ndarray | Input data array of shape (n_samples, n_features). | required |
Returns:
| Type | Description |
|---|---|
ndarray | np.ndarray: The scaled data array. |
Source code in src/dicex/preprocessing/scaling.py
transform_direction(c_scaled) ¶
Convert a direction from scaled space back to original space.
If x_scaled = (x - mu) / sigma, then a change Delta x_scaled corresponds to Delta x = Delta x_scaled * sigma.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c_scaled | ndarray | Direction vector in scaled space (unit norm). | required |
Returns:
| Type | Description |
|---|---|
ndarray | np.ndarray: Corresponding unit direction in original space. |
Source code in src/dicex/preprocessing/scaling.py
wrap_model(model) ¶
Wrap a model to accept scaled input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model | RegressorModel | ClassifierModel | The original model expecting raw data. | required |
Returns:
| Type | Description |
|---|---|
RegressorModel | ClassifierModel | RegressorModel | ClassifierModel: A model wrapper that composes model(inverse_transform(x)). |