Class: OpenTox::Crossvalidation

Inherits:
Object
  • Object
show all
Includes:
OpenTox
Defined in:
lib/validation.rb

Instance Attribute Summary collapse

Attributes included from OpenTox

#metadata, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OpenTox

#add_metadata, all, #delete, #initialize, sign_in, text_to_html, #to_rdfxml

Instance Attribute Details

#reportObject (readonly)

Returns the value of attribute report.



142
143
144
# File 'lib/validation.rb', line 142

def report
  @report
end

Class Method Details

.create(params, subjectid = nil, waiting_task = nil) ⇒ OpenTox::Crossvalidation

creates a crossvalidations, waits until it finishes, may take some time

Parameters:

  • params (Hash)

    (required:algorithm_uri,dataset_uri,prediction_feature, optional:algorithm_params,num_folds(10),random_seed(1),stratified(false))

  • subjectid (String, optional) (defaults to: nil)
  • waiting_task (OpenTox::Task, optional) (defaults to: nil)

    (can be a OpenTox::Subtask as well), progress is updated accordingly

Returns:



172
173
174
175
176
177
# File 'lib/validation.rb', line 172

def self.create( params, subjectid=nil, waiting_task=nil )
  params[:subjectid] = subjectid if subjectid
  uri = OpenTox::RestClientWrapper.post( File.join(CONFIG[:services]["opentox-validation"],"crossvalidation"),
    params,{:content_type => "text/uri-list"},waiting_task )
  Crossvalidation.new(uri)
end

.find(uri, subjectid = nil) ⇒ OpenTox::Crossvalidation

find crossvalidation, raises error if not found

Parameters:

  • uri (String)
  • subjectid (String, optional) (defaults to: nil)

Returns:



148
149
150
151
152
# File 'lib/validation.rb', line 148

def self.find( uri, subjectid=nil )
  cv = Crossvalidation.new(uri)
  cv.( subjectid )
  cv
end

.list(params = {}) ⇒ Array

returns a filtered list of crossvalidation uris

Parameters:

  • params, (Hash, optional)

    crossvalidation-params to filter the uris (could be algorithm, dataset, ..)

Returns:



157
158
159
160
161
162
163
164
165
# File 'lib/validation.rb', line 157

def self.list( params={} )
  filter_string = ""
  params.each do |k,v|
    filter_string += (filter_string.length==0 ? "?" : "&")
    v = v.to_s.gsub(/;/, "%3b") if v.to_s =~ /;/
    filter_string += k.to_s+"="+v.to_s
  end
  (OpenTox::RestClientWrapper.get(File.join(CONFIG[:services]["opentox-validation"],"crossvalidation")+filter_string).split("\n"))
end

Instance Method Details

#find_or_create_report(subjectid = nil, waiting_task = nil) ⇒ String

looks for report for this crossvalidation, creates a report if no report is found

Parameters:

  • subjectid (String, optional) (defaults to: nil)
  • waiting_task (OpenTox::Task, optional) (defaults to: nil)

    (can be a OpenTox::Subtask as well), progress is updated accordingly

Returns:



183
184
185
186
187
# File 'lib/validation.rb', line 183

def find_or_create_report( subjectid=nil, waiting_task=nil )
  @report = CrossvalidationReport.find_for_crossvalidation(@uri, subjectid) unless @report
  @report = CrossvalidationReport.create(@uri, subjectid, waiting_task) unless @report
  @report.uri
end

#load_metadata(subjectid = nil) ⇒ Object

loads metadata via yaml from crossvalidation object fields (like for example the validations) can be acces via validation.metadata



191
192
193
# File 'lib/validation.rb', line 191

def ( subjectid=nil )
  @metadata = YAML.load(OpenTox::RestClientWrapper.get(uri,{:subjectid => subjectid, :accept => "application/x-yaml"}))
end

#probabilities(confidence, prediction, subjectid = nil) ⇒ Object

documentation see OpenTox::Validation.probabilities



201
202
203
204
# File 'lib/validation.rb', line 201

def probabilities( confidence, prediction, subjectid=nil )
  YAML.load(OpenTox::RestClientWrapper.get(@uri+"/statistics/probabilities?prediction="+prediction.to_s+"&confidence="+confidence.to_s,
    {:subjectid => subjectid, :accept => "application/x-yaml"}))
end

#statistics(subjectid = nil) ⇒ Object

returns a Validation object containing the statistics of the crossavlidation



196
197
198
# File 'lib/validation.rb', line 196

def statistics( subjectid=nil )
  Validation.from_cv_statistics( @uri, subjectid )
end