jijzepttools.blackbox_optimization.surrogate_model.fmo_surrogate_model#
Classes#
Parameters for Factorization Machine surrogate model. |
|
Factorization Machine surrogate model implementation. |
Module Contents#
- class FMParams#
Bases:
jijzepttools.blackbox_optimization.surrogate_model.interface.SurrogateModelParamsParameters for Factorization Machine surrogate model.
- latent_dim#
Dimension of latent factors in FM.
- Type:
int, default=5
- warm_start#
Whether to warm start the FM model. If True, the FM model will continue training from the previous weights. If False, the FM model will be re-initialized on each fit.
- Type:
bool, default=True
- verbose#
Whether to show training progress. Set to False to disable progress display.
- Type:
bool, default=True
- optimizer_config#
Configuration for the optimizer. Use AdamConfig for mini-batch SGD with Adam, or LBFGSConfig for full-batch quasi-Newton optimization.
- Type:
AdamConfig | LBFGSConfig, default=LBFGSConfig()
- latent_dim: int = 5#
- warm_start: bool = True#
- verbose: bool = True#
- class FMSurrogateModel(n_features: int, params: FMParams | None = None, non_binary_indices: list[int] | None = None)#
Bases:
jijzepttools.blackbox_optimization.surrogate_model.interface.SurrogateModelFactorization Machine surrogate model implementation.
This model uses second-order feature interactions to approximate the objective function. The mathematical form is: f(x) = w0 + Σ wi*xi + ΣΣ <vi,vj>*xi*xj + Σ di*xi^2 (for non-binary)
- Parameters:
n_features (int) – Number of input features.
params (FMParams, optional) – Parameters for the model. If None, default parameters are used.
non_binary_indices (list[int] | None, optional) – Indices of non-binary variables (integer/continuous). If provided, diagonal terms (x_i^2) will be added for these variables. For binary variables, x^2 = x, so diagonal terms are redundant with linear terms.
- n_features#
- non_binary_indices = None#
- reset_state()#
- fit(x: numpy.ndarray, y: numpy.ndarray) None#
Fit the Factorization Machine to the data.
- Parameters:
x (np.ndarray, shape (n_samples, n_features)) – Input features.
y (np.ndarray, shape (n_samples,)) – Target values.
- predict(x: numpy.ndarray) numpy.ndarray#
Predict target values using the fitted FM model.
- surrogate_to_ommx_objective(decision_variables: list[ommx.v1.DecisionVariable])#
Create OMMX expression for the fitted FM model.
- Parameters:
decision_variables (list[ommx.v1.DecisionVariable]) – Decision variables from OMMX instance.