Class: Rumale::PolynomialModel::BaseFactorizationMachine
- Inherits:
-
Object
- Object
- Rumale::PolynomialModel::BaseFactorizationMachine
- Includes:
- Base::BaseEstimator
- Defined in:
- lib/rumale/polynomial_model/base_factorization_machine.rb
Overview
BaseFactorizationMachine is an abstract class for implementation of Factorization Machine-based estimators. This class is used internally.
Direct Known Subclasses
FactorizationMachineClassifier, FactorizationMachineRegressor
Instance Attribute Summary
Attributes included from Base::BaseEstimator
Instance Method Summary collapse
-
#initialize(n_factors: 2, loss: nil, reg_param_linear: 1.0, reg_param_factor: 1.0, max_iter: 1000, batch_size: 10, optimizer: nil, random_seed: nil) ⇒ BaseFactorizationMachine
constructor
Initialize a Factorization Machine-based estimator.
Constructor Details
#initialize(n_factors: 2, loss: nil, reg_param_linear: 1.0, reg_param_factor: 1.0, max_iter: 1000, batch_size: 10, optimizer: nil, random_seed: nil) ⇒ BaseFactorizationMachine
Initialize a Factorization Machine-based estimator.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rumale/polynomial_model/base_factorization_machine.rb', line 25 def initialize(n_factors: 2, loss: nil, reg_param_linear: 1.0, reg_param_factor: 1.0, max_iter: 1000, batch_size: 10, optimizer: nil, random_seed: nil) @params = {} @params[:n_factors] = n_factors @params[:loss] = loss unless loss.nil? @params[:reg_param_linear] = reg_param_linear @params[:reg_param_factor] = reg_param_factor @params[:max_iter] = max_iter @params[:batch_size] = batch_size @params[:optimizer] = optimizer @params[:optimizer] ||= Optimizer::Nadam.new @params[:random_seed] = random_seed @params[:random_seed] ||= srand @factor_mat = nil @weight_vec = nil @bias_term = nil @rng = Random.new(@params[:random_seed]) end |