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.SurrogateModelParams
Parameters for Factorization Machine surrogate model.
- latent_dim#
Dimension of latent factors in FM.
- Type:
int, default=5
- optimizer_params#
Parameters for PyTorch optimizer (e.g., {‘lr’: 0.001, ‘weight_decay’: 1e-4}).
- Type:
dict, default={}
- n_epochs#
Number of training epochs.
- Type:
int, default=1000
- batch_size#
Batch size for training.
- Type:
int, default=32
- early_stopping#
Whether to use early stopping.
- Type:
bool, default=True
- es_min_epochs#
Minimum number of epochs.
- Type:
int, default=10
- es_patience#
Patience for early stopping.
- Type:
int, default=10
- es_threshold_of_loss_rel_imp#
Threshold of loss relative improvement for early stopping.
- Type:
float, default=5e-4
- es_verbose#
Whether to print early stopping message.
- Type:
bool, default=False
- warm_start#
Whether to warm start the FM model. If True, the FM model will be warm started from the previous fit. If False, the FM model will be initialized in each fit.
- Type:
bool, default=True
- latent_dim: int = 5#
- optimizer_params: dict#
- n_epochs: int = 1000#
- batch_size: int = 32#
- early_stopping: bool = True#
- es_min_epochs: int = 10#
- es_patience: int = 10#
- es_threshold_of_loss_rel_imp: float = 0.0005#
- es_verbose: bool = False#
- warm_start: bool = True#
- class FMSurrogateModel(n_features: int, params: FMParams | None = None)#
Bases:
jijzepttools.blackbox_optimization.surrogate_model.interface.SurrogateModel
Factorization 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
- Parameters:
n_features (int) – Number of input features.
params (FMParams, optional) – Parameters for the model. If None, default parameters are used.
- n_features#
- fm_trainer#
- 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.