blob: 4b36aad265cd5047e03427f2c336ad292229d2c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
module OpenTox
module Model
class LazarClassification < OpenTox
# Create a new prediction model from a dataset
def initialize(uri)
super(uri)
end
def self.create(params)
uri = RestClient.post File.join(@@config[:services]["opentox-model"], 'lazar_classification'), params
puts "URI: " + uri
LazarClassification.new(uri.to_s)
end
def self.find(name)
uri = RestClient.get File.join(@@config[:services]["opentox-model"], 'lazar_classification', URI.encode(params[:name]))
LazarClassification.new(uri)
end
def self.find_all
RestClient.get File.join(@@config[:services]["opentox-model"], 'lazar_classification')#.split("\n")
end
# Predict a compound
def predict(compound)
LazarPrediction.new(:uri => RestClient.post(@uri, :compound_uri => compound.uri))
end
def self.base_uri
@@config[:services]["opentox-model"]
end
end
end
module Prediction
module Classification
class Lazar < OpenTox
def initialize(params)
super(params[:uri])
end
def classification
YAML.load(RestClient.get(@uri))[:classification]
end
def confidence
YAML.load(RestClient.get(@uri))[:confidence]
end
def neighbors
RestClient.get @uri + '/neighbors'
end
def features
RestClient.get @uri + '/features'
end
end
end
end
end
|