summaryrefslogtreecommitdiff
path: root/views/model_details.haml
blob: c95b363ea35af1f19e3f6496f4f737bb58ec78c9 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
%div.card.bg-light
  %div.card-body
    %h6.card-title Model:
    Source:
    %a{:href=>model.source, :rel=>"external"}
      = model.source
    %br
    - model.classification? ? type = "Classification" : type = "Regression"
    = "Type:\t"
    = type
    %br
    = "Training compounds:\t"
    = data_entries.count/3
    %br
    = "Training dataset:\t"
    %a{:href=>"#{to("/predict/dataset/#{training_dataset.name}")}"}
      = training_dataset.name

%div.card.bg-light
  %div.card-body
    %h6.card-title Algorithms:
    %p.card-text
      Similarity:
      %a.card-link{:href=> "http://www.rubydoc.info/gems/lazar/OpenTox%2F#{model.model.algorithms["similarity"]["method"].sub("::", "%2F")}", :rel=>"external"}
        = model.model.algorithms["similarity"]["method"]
      = ", min: #{model.model.algorithms["similarity"]["min"]}"
      %br
      Prediction:
      - if model.model.algorithms["prediction"]["method"] !~ /Caret/
        %a.card-link{:href=>"http://www.rubydoc.info/gems/lazar/OpenTox%2F#{model.model.algorithms["prediction"]["method"].sub("::","%2f")}", :rel=>"external"}
          = model.model.algorithms["prediction"]["method"]
      - else
        %a.card-link{:href=>"http://www.rubydoc.info/gems/lazar/OpenTox/Algorithm/Caret", :rel=>"external"}
          = model.model.algorithms["prediction"]["method"]

      %br
      Descriptors:
      = model.model.algorithms["descriptors"]["method"]+","
      = model.model.algorithms["descriptors"]["type"]

%div.card.bg-light
  %div.card-body
    - if type == "Classification"
      %h6.card-title #{crossvalidations.size} independent 10-fold crossvalidations:
    - else
      %h6.card-title #{crossvalidations.size} independent 10-fold crossvalidations (-log10 transformed):
    - crossvalidations.each_with_index do |cv,idx|
      %p.card-text
        - if model.classification?
          / accuracy, confusion matrixes
          - av = cv.accept_values
          - keys = cv.accuracy.collect{|key, value| key}
          - acc = cv.accuracy.collect{|key, value| value.signif(3)}
          - tpr = cv.true_rate.collect{|key, hash| hash[av[0]].signif(3)}
          - fpr = cv.true_rate.collect{|key, hash| hash[av[1]].signif(3)}
          - pp = cv.predictivity.collect{|key, hash| hash[av[0]].signif(3)}
          - np = cv.predictivity.collect{|key, hash| hash[av[1]].signif(3)}
          %table.table.table-borderless.table-responsive
            %tr
              %td.text-center
                = "Nr.#{idx+1}"
              %td Accuracy
              %td
                %a{:href=>"https://en.wikipedia.org/wiki/Sensitivity_and_specificity", :rel=>"external"}
                  True #{av[0] =~ /^non/ ? "negative" : "positive"} rate
              %td
                %a{:href=>"https://en.wikipedia.org/wiki/Sensitivity_and_specificity", :rel=>"external"}
                  True #{av[1] =~ /^non/ ? "negative" : "positive"} rate
              %td #{av[0] =~ /^non/ ? "Negative" : "Positive"} predictiv value
              %td #{av[1] =~ /^non/ ? "Negative" : "Positive"} predictiv value
            - keys.each_with_index do |key,idx|
              %tr
                / keys
                %td.fit.text-right.pr-0= key.gsub("_", " ")
                / acc,accuray value:
                %td= acc[idx]
                / tpr,true positive rate
                %td= tpr[idx]
                / fpr,false positive rate
                %td= fpr[idx]
                / pp,positive predictions
                %td= pp[idx]
                / np,negative predictions
                %td= np[idx]
          %div.row
            %button.btn.btn-outline-info.mx-auto{:type=>"button", :data=>{:toggle=>"collapse", :target=>"#matrix#{idx}"}, :aria=>{:expanded=>"false", :controls=>"matrix#{idx}"}, :style=>"font-size:small;"}
              Confusion matrix:
          %div.collapse{:id=>"matrix#{idx}"}
            %table.table.table-borderless.table-responsive
              %tr
                %td.fit.text-center all
                %td.fit.text-center confidence high
                %td.fit.text-center confidence low
              %tr
                / confusion matrix
                - keys.each do |key|
                  - matrix = cv.confusion_matrix[key]
                  %td.fit.text-right
                    %table.table-sm
                      %tr
                        %td
                        %td
                        %td
                          %h6 actual
                        %td
                      %tr
                        %td
                        %td
                        %td active
                        %td inactive
                      %tr
                        %td
                          %h6 predicted
                        %td active
                        %td
                          = matrix[0][0]
                        %td
                          = matrix[0][1]
                      %tr
                        %td
                        %td inactive
                        %td
                          = matrix[1][0]
                        %td
                          = matrix[1][1]
        
        / regression
        - if model.regression?
          / rmse, mae, r_squared, pred nr, within intv, out intv
          - keys = cv.rmse.collect{|key, value| key}
          - rmse = cv.rmse.collect{|key, value| value.signif(3)}
          - mae = cv.mae.collect{|key, value| value.signif(3)}
          - rsq = cv.r_squared.collect{|key, value| value.signif(3)}
          - nrp = cv.nr_predictions.collect{|key,value| value}
          - wpi = cv.within_prediction_interval.collect{|key,value| value}
          - opi = cv.out_of_prediction_interval.collect{|key,value| value}
          %table.table.table-borderless.table-responsive
            %tr
              %td.text-center
                = "Nr.#{idx+1}"
              %td
                %a{:href=>"https://en.wikipedia.org/wiki/Root-mean-square_deviation", :rel=>"external"}
                  RMSE
              %td
                %a{:href=>"https://en.wikipedia.org/wiki/Mean_absolute_error", :rel=>"external"}
                  MAE
              %td
                %a{:href=>"https://en.wikipedia.org/wiki/Coefficient_of_determination", :rel=>"external"}= "R"+"<sup>2</sup>"
              %td Number of predictions
              %td Within prediction interval
              %td Out of prediction interval
            - keys.each_with_index do |key,idx|
              %tr
                / keys
                %td.fit.text-right.pr-0= key.gsub("_", " ")
                / rsme:
                %td= rmse[idx]
                / mae:
                %td= mae[idx]
                / r_squared:
                %td= rsq[idx]
                / Predictions number:
                %td= nrp[idx]
                / Within prediction interval:
                %td= wpi[idx]
                / Out of prediction interval:
                %td= opi[idx]
        - unless idx == crossvalidations.size-1
          %hr

%div.card.bg-light
  %div.card-body
    %h6.card-title QMRF:
    %a.btn.btn-outline-info{:href=>"#{to("/predict/report/#{model.id}")}", :id=>"report#{model.id}", :style=>"font-size:small;"}
      %span.fa.fa-download
      XML
%br