Class: Rumale::NeuralNetwork::RVFLRegressor
- Inherits:
-
BaseRVFL
- Object
- Base::Estimator
- BaseRVFL
- Rumale::NeuralNetwork::RVFLRegressor
- Includes:
- Base::Regressor
- Defined in:
- rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb
Overview
RVFLRegressor is a class that implements regressor based on random vector functional link (RVFL) network. The current implementation uses sigmoid function as activation function.
Reference
-
Malik, A. K., Gao, R., Ganaie, M. A., Tanveer, M., and Suganthan, P. N., “Random vector functional link network: recent developments, applications, and future directions,” Applied Soft Computing, vol. 143, 2023.
-
Zhang, L., and Suganthan, P. N., “A comprehensive evaluation of random vector functional link networks,” Information Sciences, vol. 367–368, pp. 1094–1105, 2016.
Instance Attribute Summary collapse
-
#random_bias ⇒ Numo::DFloat
readonly
Return the bias vector in the hidden layer of RVFL network.
-
#random_weight_vec ⇒ Numo::DFloat
readonly
Return the weight vector in the hidden layer of RVFL network.
-
#rng ⇒ Random
readonly
Return the random generator.
-
#weight_vec ⇒ Numo::DFloat
readonly
Return the weight vector.
Attributes inherited from Base::Estimator
Instance Method Summary collapse
-
#fit(x, y) ⇒ RVFLRegressor
Fit the model with given training data.
-
#initialize(hidden_units: 128, reg_param: 100.0, scale: 1.0, random_seed: nil) ⇒ RVFLRegressor
constructor
Create a new regressor with RVFL network.
-
#predict(x) ⇒ Numo::DFloat
Predict values for samples.
Methods included from Base::Regressor
Constructor Details
#initialize(hidden_units: 128, reg_param: 100.0, scale: 1.0, random_seed: nil) ⇒ RVFLRegressor
Create a new regressor with RVFL network.
50 51 52 |
# File 'rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb', line 50 def initialize(hidden_units: 128, reg_param: 100.0, scale: 1.0, random_seed: nil) super end |
Instance Attribute Details
#random_bias ⇒ Numo::DFloat (readonly)
Return the bias vector in the hidden layer of RVFL network.
34 35 36 |
# File 'rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb', line 34 def random_bias @random_bias end |
#random_weight_vec ⇒ Numo::DFloat (readonly)
Return the weight vector in the hidden layer of RVFL network.
30 31 32 |
# File 'rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb', line 30 def random_weight_vec @random_weight_vec end |
#rng ⇒ Random (readonly)
Return the random generator.
42 43 44 |
# File 'rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb', line 42 def rng @rng end |
#weight_vec ⇒ Numo::DFloat (readonly)
Return the weight vector.
38 39 40 |
# File 'rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb', line 38 def weight_vec @weight_vec end |
Instance Method Details
#fit(x, y) ⇒ RVFLRegressor
Fit the model with given training data.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb', line 59 def fit(x, y) x = ::Rumale::Validation.check_convert_sample_array(x) y = ::Rumale::Validation.check_convert_target_value_array(y) ::Rumale::Validation.check_sample_size(x, y) raise 'RVFLRegressor#fit requires Numo::Linalg but that is not loaded.' unless enable_linalg?(warning: false) y = y.(1) if y.ndim == 1 partial_fit(x, y) self end |
#predict(x) ⇒ Numo::DFloat
Predict values for samples.
76 77 78 79 80 81 82 83 |
# File 'rumale-neural_network/lib/rumale/neural_network/rvfl_regressor.rb', line 76 def predict(x) x = ::Rumale::Validation.check_convert_sample_array(x) h = hidden_output(x) out = h.dot(@weight_vec) out = out[true, 0] if out.shape[1] == 1 out end |