FactorizationMachine

class FactorizationMachine

Bases: object

Factorization Machine model implemented in pure NumPy.

Methods

__init__

Initializes the Factorization Machine model.

forward

Computes the forward pass of the model.

Attributes

bias

Returns the bias term of the model.

linear

Returns the linear weights of the model.

num_factors

Returns the number of factors in the model.

num_features

Returns the number of input features in the model.

quadratic

Returns the quadratic weights of the model.

__call__(x: ndarray) → ndarray

Computes the forward pass of the model.

Parameters:

x (np.ndarray) – The input array of shape (n_samples, n_features).

Returns:

The output array of shape (n_samples,).

Return type:

np.ndarray

__init__(d: int, k: int, seed: int | SeedSequence | None = None) → None

Initializes the Factorization Machine model.

Parameters:
  • d (int) – The number of input features.

  • k (int) – The number of factors.

  • seed (int | np.random.SeedSequence | None, optional) – The seed for the random initialization. If None (default), a non-deterministic seed is used.

forward(x: ndarray) → ndarray

Computes the forward pass of the model.

Parameters:

x (np.ndarray) – The input array of shape (n_samples, n_features).

Returns:

The output array of shape (n_samples,).

Return type:

np.ndarray

__dict__ = mappingproxy({'__module__': 'amplify_bbopt.trainer', '__doc__': 'Factorization Machine model implemented in pure NumPy.', '__init__': <function FactorizationMachine.__init__>, 'num_factors': <property object>, 'num_features': <property object>, 'quadratic': <property object>, 'linear': <property object>, 'bias': <property object>, 'forward': <function FactorizationMachine.forward>, '__call__': <function FactorizationMachine.forward>, '__dict__': <attribute '__dict__' of 'FactorizationMachine' objects>, '__weakref__': <attribute '__weakref__' of 'FactorizationMachine' objects>, '__annotations__': {}})
__weakref__

list of weak references to the object (if defined)

property bias: ndarray

Returns the bias term of the model.

property linear: ndarray

Returns the linear weights of the model.

property num_factors: int

Returns the number of factors in the model.

property num_features: int

Returns the number of input features in the model.

property quadratic: ndarray

Returns the quadratic weights of the model.