Class: Experiment::Factorial
Defined Under Namespace
Modules: DistributedFactorial
Instance Attribute Summary collapse
-
#parent_dir ⇒ Object
Returns the value of attribute parent_dir.
Attributes inherited from Base
#current_cv, #cvs, #dir, #output_file
Class Method Summary collapse
-
.param(name, value = nil, &block) ⇒ Object
(also: independent_variable)
Specify a parameter that will be used as a factor in the experiment.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Factorial
constructor
A new instance of Factorial.
-
#normal_run!(cv) ⇒ Object
runs the whole experiment.
Methods inherited from Base
after_completion, #analyze_result!, #benchmark, #data_set, #done?, #measure, #run!, #test_data, #training_data
Constructor Details
#initialize(*args) ⇒ Factorial
Returns a new instance of Factorial.
45 46 47 48 |
# File 'lib/experiment/factorial.rb', line 45 def initialize(*args) super(*args) @params ||= {} end |
Instance Attribute Details
#parent_dir ⇒ Object
Returns the value of attribute parent_dir.
43 44 45 |
# File 'lib/experiment/factorial.rb', line 43 def parent_dir @parent_dir end |
Class Method Details
.param(name, value = nil, &block) ⇒ Object Also known as: independent_variable
Specify a parameter that will be used as a factor in the experiment
31 32 33 34 35 36 37 38 |
# File 'lib/experiment/factorial.rb', line 31 def param(name, value = nil, &block) @@params ||= {} if block_given? @@params[name] = block.call else @@params[name] = value end end |
Instance Method Details
#normal_run!(cv) ⇒ Object
runs the whole experiment
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/experiment/factorial.rb', line 52 def normal_run!(cv) @cvs = cv || 1 @results = {} puts "Running #{@experiment} with #{param_grid.length} experiments at #{cv} cross validations each..." #experiments = Notify.total / cv #Notify.total = (experiments - 1) * cv + cv * param_grid.length # Notify::init param_grid.length * @options.cv, STDOUT, Experiment::Config::get(:growl_notifications, false) split_up_data write_dir! param_grid.each do |paramset| Params.set paramset results = {} Notify.started @experiment + ' ' + param_string(paramset, ", ") @cvs.times do |cv_num| @bm = [] @current_cv = cv_num File.open(@dir + "/raw-#{param_string(paramset)}-#{cv_num}.txt", "w") do |output| @ouptut_file = output run_the_experiment(@data[cv_num], output) end array_merge results, analyze_result!(@dir + "/raw-#{param_string(paramset)}-#{cv_num}.txt", @dir + "/analyzed-#{param_string(paramset)}-#{cv_num}.txt") write_performance! Notify.cv_done @experiment + ' ' + param_string(paramset, ", "), cv_num #Notify.inc step end #print '.' Notify.completed @experiment + ' ' + param_string(paramset, ", ") @results[paramset] = results end Notify::done specification! summarize_performance! summarize_results! @results cleanup! puts File.read(@dir + "/summary.mmd") if @options.summary end |