Module: Ai4r::Data::Parameterizable
- Included in:
- Classifiers::Classifier, Clusterers::Clusterer, NeuralNetwork::Backpropagation, NeuralNetwork::Hopfield, Som::Layer, Som::Node, Som::Som
- Defined in:
- lib/ai4r/data/parameterizable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#get_parameters ⇒ Object
Get parameter values on this algorithm instance.
-
#set_parameters(params) ⇒ Object
Set parameter values on this algorithm instance.
Class Method Details
.included(base) ⇒ Object
57 58 59 |
# File 'lib/ai4r/data/parameterizable.rb', line 57 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#get_parameters ⇒ Object
Get parameter values on this algorithm instance. Returns a hash with the folowing format: { :param_name => parameter_value }
49 50 51 52 53 54 55 |
# File 'lib/ai4r/data/parameterizable.rb', line 49 def get_parameters params = {} self.class.get_parameters_info.keys.each do | key | params[key] = send(key) if self.respond_to?(key) end return params end |
#set_parameters(params) ⇒ Object
Set parameter values on this algorithm instance. You must provide a hash with the folowing format: { :param_name => parameter_value }
37 38 39 40 41 42 43 44 |
# File 'lib/ai4r/data/parameterizable.rb', line 37 def set_parameters(params) self.class.get_parameters_info.keys.each do | key | if self.respond_to?("#{key}=".to_sym) send("#{key}=".to_sym, params[key]) if params.has_key? key end end return self end |