Class: PythonModel

Inherits:
VectorModel show all
Defined in:
lib/rbbt/vector/model/python.rb

Direct Known Subclasses

TorchModel

Instance Attribute Summary collapse

Attributes inherited from VectorModel

#balance, #bar, #directory, #eval_model, #extract_features, #factor_levels, #features, #init_model, #labels, #model, #model_options, #model_path, #names, #post_process, #train_model

Instance Method Summary collapse

Methods inherited from VectorModel

R_eval, R_run, R_train, #__load_method, #add, #add_list, #balance_labels, #clear, #cross_validation, #eval, #eval_list, f1_metrics, #init, #run, #save_models, #train

Constructor Details

#initialize(dir, python_class = nil, python_module = nil, model_options = nil) ⇒ PythonModel

Returns a new instance of PythonModel.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rbbt/vector/model/python.rb', line 9

def initialize(dir, python_class = nil, python_module = nil, model_options = nil)
  python_module = :model if python_module.nil?
  model_options, python_module = python_module, :model if model_options.nil? && Hash === python_module
  model_options = {} if model_options.nil?

  super(dir, model_options)

  @python_class = python_class
  @python_module = python_module

  init_model do
    RbbtPython.add_path @directory 
    RbbtPython.class_new_obj(@python_module, @python_class, **model_options)
  end if python_class

  eval_model do |features,list=false|
    init
    if list
      model.eval(features)
    else
      model.eval([features])[0]
    end
  end
end

Instance Attribute Details

#python_classObject

Returns the value of attribute python_class.



8
9
10
# File 'lib/rbbt/vector/model/python.rb', line 8

def python_class
  @python_class
end

#python_moduleObject

Returns the value of attribute python_module.



8
9
10
# File 'lib/rbbt/vector/model/python.rb', line 8

def python_module
  @python_module
end