Class: Rumale::NeuralNetwork::RBFRegressor
- Inherits:
-
BaseRBF
- Object
- Base::Estimator
- BaseRBF
- Rumale::NeuralNetwork::RBFRegressor
- Includes:
- Base::Regressor
- Defined in:
- rumale-neural_network/lib/rumale/neural_network/rbf_regressor.rb
Overview
RBFRegressor is a class that implements regressor based on (k-means) radial basis function (RBF) networks.
Reference
-
Bugmann, G., “Normalized Gaussian Radial Basis Function networks,” Neural Computation, vol. 20, pp. 97–110, 1998.
-
Que, Q., and Belkin, M., “Back to the Future: Radial Basis Function Networks Revisited,” Proc. of AISTATS’16, pp. 1375–1383, 2016.
Instance Attribute Summary collapse
-
#centers ⇒ Numo::DFloat
readonly
Return the centers in the hidden layer of RBF 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) ⇒ MLPRegressor
Fit the model with given training data.
-
#initialize(hidden_units: 128, gamma: nil, reg_param: 100.0, normalize: false, max_iter: 50, tol: 1e-4, random_seed: nil) ⇒ RBFRegressor
constructor
Create a new regressor with (k-means) RBF networks.
-
#predict(x) ⇒ Numo::DFloat
Predict values for samples.
Methods included from Base::Regressor
Constructor Details
#initialize(hidden_units: 128, gamma: nil, reg_param: 100.0, normalize: false, max_iter: 50, tol: 1e-4, random_seed: nil) ⇒ RBFRegressor
Create a new regressor with (k-means) RBF networks.
48 49 50 51 |
# File 'rumale-neural_network/lib/rumale/neural_network/rbf_regressor.rb', line 48 def initialize(hidden_units: 128, gamma: nil, reg_param: 100.0, normalize: false, max_iter: 50, tol: 1e-4, random_seed: nil) super end |
Instance Attribute Details
#centers ⇒ Numo::DFloat (readonly)
Return the centers in the hidden layer of RBF network.
29 30 31 |
# File 'rumale-neural_network/lib/rumale/neural_network/rbf_regressor.rb', line 29 def centers @centers end |
#rng ⇒ Random (readonly)
Return the random generator.
37 38 39 |
# File 'rumale-neural_network/lib/rumale/neural_network/rbf_regressor.rb', line 37 def rng @rng end |
#weight_vec ⇒ Numo::DFloat (readonly)
Return the weight vector.
33 34 35 |
# File 'rumale-neural_network/lib/rumale/neural_network/rbf_regressor.rb', line 33 def weight_vec @weight_vec end |
Instance Method Details
#fit(x, y) ⇒ MLPRegressor
Fit the model with given training data.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'rumale-neural_network/lib/rumale/neural_network/rbf_regressor.rb', line 58 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 'RBFRegressor#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.
75 76 77 78 79 80 81 82 |
# File 'rumale-neural_network/lib/rumale/neural_network/rbf_regressor.rb', line 75 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 |