Preprocessing and model-selection API
CapacityNormalizer
Min-max transformer with optional cost-criterion reversal. It is scikit-learn compatible and preserves feature names through get_feature_names_out().
CapacityNormalizer
CapacityNormalizer(
feature_range: tuple[float, float] = (0.0, 1.0),
cost_features: Sequence[int | str] | None = None,
clip: bool = True,
)
Bases: TransformerMixin, BaseEstimator
Scale commensurable capacity inputs and orient cost features.
Each feature is independently min-max scaled. Selected cost criteria are then reversed so that larger transformed values consistently represent more desirable outcomes, as required by monotone Choquet models.
Parameters
feature_range : tuple of float, default=(0.0, 1.0) Desired lower and upper bounds of transformed features. cost_features : sequence of int or str, optional Indices or DataFrame column names whose direction must be reversed. clip : bool, default=True Whether values outside the fitted range are clipped during transform.
Attributes
data_min_ : ndarray of shape (n_features,)
Per-feature minima observed during fitting.
data_max_ : ndarray of shape (n_features,)
Per-feature maxima observed during fitting.
scale_ : ndarray of shape (n_features,)
Multiplicative scaling factors.
cost_features_ : ndarray of int
Resolved indices of reversed features.
n_features_in_ : int
Number of features seen during :meth:fit.
feature_names_in_ : ndarray of str
Feature names seen during fitting when X provides string columns.
Source code in src/capacities_ml_fin/ml/preprocessing/normalization.py
fit
Learn feature ranges and resolve cost-feature names.
Source code in src/capacities_ml_fin/ml/preprocessing/normalization.py
transform
Transform features into the configured capacity range.
Source code in src/capacities_ml_fin/ml/preprocessing/normalization.py
inverse_transform
Undo the normalization and cost-feature reversal.
Source code in src/capacities_ml_fin/ml/preprocessing/normalization.py
get_feature_names_out
Return feature names unchanged.
Source code in src/capacities_ml_fin/ml/preprocessing/normalization.py
Capacity sparsity grids
capacity_sparsity_grid
capacity_sparsity_grid
capacity_sparsity_grid(
orders: Iterable[int],
*,
shapes: Iterable[CapacityShape] = (GENERAL,)
) -> list[CapacitySparsity]
Build sparsity candidates for capacity model selection.
Source code in src/capacities_ml_fin/ml/model_selection/grids.py
capacity_shape_grid
capacity_shape_grid
capacity_shape_grid(
*,
order: int = 2,
shapes: Iterable[CapacityShape] = (
GENERAL,
CONVEX,
CONCAVE,
)
) -> list[CapacitySparsity]
Build candidates that compare capacity shapes at one order.
Source code in src/capacities_ml_fin/ml/model_selection/grids.py
interaction_order_grid
interaction_order_grid
interaction_order_grid(
orders: Iterable[int], *, shape: CapacityShape = GENERAL
) -> list[CapacitySparsity]
Build candidates that compare the maximum interaction order.
Source code in src/capacities_ml_fin/ml/model_selection/grids.py
pairwise_interaction_grid
pairwise_interaction_grid
pairwise_interaction_grid(
orders: Iterable[int],
*,
pairs: tuple[tuple[int, int], ...] | None = None,
target: float = 0.0,
shape: CapacityShape = GENERAL
) -> list[CapacitySparsity]
Build candidates with selected pairwise interactions fixed.
Source code in src/capacities_ml_fin/ml/model_selection/grids.py
capacity_parameter_grid
Convenience wrapper returning a dictionary ready for scikit-learn GridSearchCV.
capacity_parameter_grid
capacity_parameter_grid(
*,
parameter_name: str = "sparsity",
orders: Iterable[int] = (1, 2),
shapes: Iterable[CapacityShape] = (GENERAL,)
) -> dict[str, list[CapacitySparsity]]
Return a parameter grid ready for GridSearchCV.