summaryrefslogtreecommitdiff
path: root/views/predict.haml
blob: 5d5d6f08a3d15ea82dd79291b5c4e5bb6bb911df (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
:javascript
  function showcircle() {
    $("img.circle").show();
  };

%div.well
  %h3.help-block
    Select an endpoint:
  #tabs
    %ul.nav.nav-tabs{:id=>"modelTab", :role=>"tablist"}
      - @prediction_models.each_with_index do |m, idx|
        %li{:class => ("active" if idx == 0)}
          %a{:href => "#model_#{idx}", :id => "linkTab#{idx}", data: {toggle:"tab"}}
            = "#{idx+1}. #{m.model.feature_selection_algorithm_parameters[:category].nil? ? "Physchem & Proteomics" : "Physchem" }"
    %div.tab-content
      - @prediction_models.each_with_index do |m, idx|
        - m[:pc_model] ? (example = @example_pc; type = "pc"; relevant_features = @pc_relevant_features) : (example = @example_pcp; type = "pcp"; relevant_features = @pcp_relevant_features)
        #model.tab-pane{:id=>"#{idx}", :class => ("active" if idx == 0)}
          %b Model:
          %br
          Name:
          = m.model.name
          %br
          Type: regression
          %br
          Source:
          %a{:href=>"#{m.source}", :alt=>"source", :rel=>"external"}
            = m.source
          %br
          Species:
          = m.species
          %br
          Training nanoparticles:
          = m.model.training_dataset.nanoparticles.size
          %br
          Endpoint:
          = m.endpoint
          %br
          Unit:
          = m.unit
          %br
          Prediction algorithm:
          = m.model.prediction_algorithm.split(".").last.gsub("_"," ")
          %br
          Prediction algorithm parameter:
          = "random forest" if m.model.prediction_algorithm_parameters["method"] == "rf"
          %br
          Neighbor algorithm:
          = m.model.neighbor_algorithm.gsub("_", " ")
          %br
          Neighbor algorithm parameter:
          = "min sim = #{m.model.neighbor_algorithm_parameters["min_sim"]}"
          %p
          %b Independent crossvalidations (log2 transformed):
          - crossvalidations =[]
          - m.repeated_crossvalidation.crossvalidation_ids.each{|cv| c = OpenTox::Validation::CrossValidation.find(cv); crossvalidations << c}
          %div.row{:id=>"validations#{m.id}", :style=>"background-color:#f5f5f5;"}
            - crossvalidations.each do |cv|
              %span.col-xs-4.col-sm-4.col-md-4.col-lg-4
                = "Num folds:\t"
                = cv.folds
                %br
                = "Num instances:\t"
                = cv.nr_instances
                %br
                = "Num unpredicted"
                = cv.nr_unpredicted
                %br
                %a.ht5{:href=>"https://en.wikipedia.org/wiki/Root-mean-square_deviation", :rel=>"external"} RMSE:
                = cv.rmse.round(3) if cv.rmse
                %br
                %a.ht5{:href=>"https://en.wikipedia.org/wiki/Mean_absolute_error", :rel=>"external"} MAE:
                = cv.mae.round(3) if cv.mae
                %br 
                %a.ht5{:href=>"https://en.wikipedia.org/wiki/Coefficient_of_determination", :rel=>"external"}= "R"+"<sup>2</sup>"+":"
                = cv.r_squared.round(3) if cv.r_squared
          %br
          %b QMRF report
          %p
          %a.btn.btn-default{:href=>to('/qmrf-report/'+m.id), :rel=>"external"} download
          %hr
          %form{:id=>idx, :role=>"form", :action=> to("/predict"), :method=>"post"}
            %h3.help-block
              Please characterise a nanoparticle:
            #input
            %div.form-group
              // type pcp || pc
              %input{:id=>"type",:type=>"hidden",:name=>"type",:value=>"#{type}"}
              // example data to compare
              %input{:id=>"example_core",:type=>"hidden",:name=>"example_core",:value=>"#{example.core}"}
              %input{:id=>"example_coating",:type=>"hidden",:name=>"example_coating",:value=>"#{example.coating}"}
              %input{:id=>"example_pc",:type=>"hidden",:name=>"example_pc",:value=>"#{example.physchem_descriptors}"}
              - size = relevant_features.size
              %input{:id=>"size",:type=>"hidden",:name=>"size",:value=>size}
              %input{:id=>"id",:type=>"hidden",:name=>"example_id",:value=>example.id}
              // input form parameters to transfer
              %div.form-group
                %label{:for=>"selCore#{idx}"} Core
                /%p= example.core["name"]
                %select.form-control{:id=>"selCore#{idx}", :autocomplete=>"off", :name=>"input_core",:value=>example.core["name"]}
                  %option{:selected => ("selected" if example.core["name"] == "Ag")} Ag
                  %option{:selected => ("selected" if example.core["name"] == "Au")} Au
              %input{:id=>"input_core",:type=>"hidden",:name=>"in_core",:value=>"#{example.core}"}
              //%h5 Coating
              //%input.input-sm.form-control{:id=>"coating",:type=>"text",:disabled=>"disabled",:name=>"coating",:value=>example.coating[0]["name"]}
              %input.input-sm.form-control{:id=>"coating",:type=>"hidden",:name=>"input_coating",:value=>example.coating[0]["name"]}
              %input{:id=>"input_coating",:type=>"hidden",:name=>"in_coating",:value=>example.coating}
              // prediction model id 
              %input{:id=>"prediction_model",:type=>"hidden",:name=>"prediction_model",:value=>m.id}
            - relevant_features.sort_by{|d| d.category}.each_with_index do |relf,id|
              - feature = relf
              - v = example.physchem_descriptors.find{|id,v| id == feature.id.to_s  }
              - name = feature.name
              - if feature[:conditions] && !feature[:conditions]["MEDIUM"].blank?
                - name = feature.name + " / " + feature[:conditions]["MEDIUM"]
              - else
                - name = feature.name
              - val = !v.nil? ? v[1] : "-"
              - id = id + 1
              - if feature.category == "Proteomics"
                %h5
                  %a{:href=>"http://www.uniprot.org/uniprot/#{name}", :rel=>"external"}= name
              - else
                / prepare name string for npo_search
                - string = name.split("/").first.downcase.gsub(/%s/, "%20")
                %h5
                  %a{:href=>$npo_search % string, :rel=>"external"}= name
              // input physchem parameters
              %input.input-sm.form-control{:id=>id,:type=>"text",:name=>"input_value_#{id}",:value=>"#{val[0] if val[0]}", :disabled=>("disabled" if val[0] == "-")}
              - if val[0] == "-"
                %input{:id=>id,:type=>"hidden",:name=>"input_value_#{id}",:value=>"-"}
              %input{:id=>id,:type=>"hidden",:name=>"input_key_#{id}",:value=>feature.id}
            %hr
            #predict
              %button.btn.btn-success{:id=>"submitbutton", :type=>"submit", :onclick=>"showcircle();"} 
                Find similar nano particles
                %span.glyphicon.glyphicon-chevron-right{:id=>"span"}
              %img{:src=>"/images/wait30trans.gif", :id=>"circle", :class=>"circle", :alt=>"wait", :style=>"display:none;"}