Class: OpenTox::Crossvalidation

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

Instance Attribute Summary collapse

Attributes included from OldOpenTox

#metadata, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OldOpenTox

#delete, #initialize

Instance Attribute Details

#reportObject (readonly)

Returns the value of attribute report


159
160
161
# File 'lib/validation.rb', line 159

def report
  @report
end

Class Method Details

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

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


187
188
189
190
191
192
# File 'lib/validation.rb', line 187

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

.find(uri) ⇒ OpenTox::Crossvalidation

find crossvalidation, raises error if not found


164
165
166
167
168
# File 'lib/validation.rb', line 164

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

.list(params = {}) ⇒ Array

returns a filtered list of crossvalidation uris


173
174
175
176
177
178
179
180
181
# File 'lib/validation.rb', line 173

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($validation[:uri],"crossvalidation")+filter_string).split("\n"))
end

Instance Method Details

#find_or_create_report(waiting_task = nil) ⇒ String

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


197
198
199
200
201
# File 'lib/validation.rb', line 197

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

#load_metadataObject

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


205
206
207
# File 'lib/validation.rb', line 205

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

#probabilities(confidence, prediction) ⇒ Object

documentation see OpenTox::Validation.probabilities


215
216
217
218
# File 'lib/validation.rb', line 215

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

#statisticsObject

returns a Validation object containing the statistics of the crossavlidation


210
211
212
# File 'lib/validation.rb', line 210

def statistics
  Validation.from_cv_statistics( @uri )
end