diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/neighbors.haml | 20 | ||||
-rw-r--r-- | views/predict.haml | 201 | ||||
-rw-r--r-- | views/prediction.haml | 9 |
3 files changed, 118 insertions, 112 deletions
diff --git a/views/neighbors.haml b/views/neighbors.haml index 69034b3..70bf4b8 100644 --- a/views/neighbors.haml +++ b/views/neighbors.haml @@ -10,6 +10,7 @@ %ul.nav.nav-tabs.nav-justified{:id=>"neighborTabs", :role=>"tablist"} / each model a tab head ; - @models.each_with_index do |model,i| + - @type = model.model.class.to_s.match("Classification") ? "Classification" : "Regression" %li{:class => ("active" if i == 0)} %a{:href => "#results_#{i+1}", :id => "linkTab#{i+1}", data: {toggle:"tab"}} = "#{model.endpoint} (#{model.species})" @@ -31,7 +32,8 @@ headerTemplate: '{content} {icon}', widgets: ['zebra', 'columns', 'uitheme'], headers: {0: {sorter: false}, 3: {sorter: false}}, - sortList: [[2,1]] + sortList: [[2,1]], + widthFixed: false }); }); - if prediction[:neighbors].size > 0 @@ -59,16 +61,20 @@ %tbody - prediction[:neighbors].each_with_index do |neighbor,count| %tr - %td{:style =>"vertical-align:middle;padding-left:1em;"} + / Compound + %td{:style =>"vertical-align:middle;padding-left:1em;width:50%;"} /%a.btn.btn-link{:href => "#details#{j+1}", data: { toggle: "modal", remote: to("/prediction/#{CGI.escape(neighbor[0].to_s)}/details"), :id=>"link#{j+1}#{count}"}} %p= Compound.find(neighbor[0]).svg %p= Compound.find(neighbor[0]).smiles - %td{:style =>"vertical-align:middle;padding-left:1em;"} - -#= neighbor[2].collect{|n| '%.2e' % n}.join ", " - = neighbor[2].join ", " - %td{:style =>"vertical-align:middle;padding-left:1em;"} + / Measured Activity + %td{:style =>"vertical-align:middle;padding-left:1em;width:20%;"} + //= neighbor[2].collect{|n| '%.2e' % n}.join ", " + //= neighbor[2].join ", " + = (@type == "Regression") ? neighbor[2].collect{|n| n.round(2)}.join(", ") : neighbor[2].join(", ") + / Similarity + %td{:style =>"vertical-align:middle;padding-left:1em;width:20%;"} / TODO differentiate between no neighbors found and compound found in dataset, display neighbors for compounds in dataset? - = neighbor[1] != nil ? neighbor[1] : "Not enough similar compounds in training dataset." + = neighbor[1] != nil ? neighbor[1].round(2) : "Not enough similar compounds in training dataset." - else %span.btn.btn-default.disabled Not enough similar compounds in training dataset diff --git a/views/predict.haml b/views/predict.haml index 0e6b3cc..1d75723 100644 --- a/views/predict.haml +++ b/views/predict.haml @@ -144,7 +144,7 @@ %br = "Algorithm:\tLAZAR" %br - - model.classification? ? type = "classification" : type = "regression" + - model.classification? ? type = "Classification" : type = "Regression" = "Type:\t" = type %br @@ -155,108 +155,107 @@ = "Training compounds:\t" = training_dataset.compounds.size - %p %b Validation (repeated): - %p - - model.crossvalidations.each do |crossvalidation| - - cv = OpenTox::CrossValidation.find crossvalidation.id - = "Num folds:\t" - = cv.folds - %br - = "Num instances:\t" - = cv.nr_instances - %br - = "Num unpredicted" - = cv.nr_unpredicted - - if model.classification? - %br - = "Accuracy:\t" - = cv.accuracy.round(3) if cv.accuracy - %br - = "Weighted Accuracy:\t" - = cv.weighted_accuracy.round(3) if cv.weighted_accuracy - %br - = "True positive rate:\t" - = cv.true_rate["active"].round(3) if cv.true_rate["active"] - %br - = "True negative rate:\t" - = cv.true_rate["inactive"].round(3) if cv.true_rate["inactive"] - %br - = "Positive predictive value:\t" - = cv.predictivity["active"].round(3) if cv.predictivity["active"] - %br - = "Negative predictive value:\t" - = cv.predictivity["inactive"].round(3) if cv.predictivity["inactive"] - %p - %b Confusion Matrix: - %table.table.table-condensed.table-borderless{:style=>"width:20%;"} - %tbody - %tr - %td - %td - %td - %b actual - %td - %td - %tr - %td - %td - %td active - %td inactive - %td total - %tr - %td - %b predicted - %td active - %td - =cv.confusion_matrix[0][0] - %td - =cv.confusion_matrix[0][1] - %td - =cv.confusion_matrix[0][0]+cv.confusion_matrix[0][1] - %tr - %td - %td inactive - %td - =cv.confusion_matrix[1][0] - %td - =cv.confusion_matrix[1][1] - %td - =cv.confusion_matrix[1][0]+cv.confusion_matrix[1][1] - %tr - %td - %td total - %td - =cv.confusion_matrix[0][0]+cv.confusion_matrix[1][0] - %td - =cv.confusion_matrix[0][1]+cv.confusion_matrix[1][1] - %td - -#= "Confusion Matrix:\t" - -#= cv.confusion_matrix - - if model.regression? - %br - = "Root mean squared error:\t" - = cv.rmse.round(3) if cv.rmse - %br - = "Weighted root mean squared error:\t" - = cv.weighted_rmse.round(3) if cv.weighted_rmse - %br - = "Mean absolute error:\t" - = cv.mae.round(3) if cv.mae - %br - = "Weighted mean absolute error:\t" - = cv.weighted_mae.round(3) if cv.weighted_mae - %br - = "R square:\t" - = cv.r_squared.round(3) if cv.r_squared - /%br - /= "Correlation plot" - /= cv.correlation_plot - /%br - /= "Confidence plot:" - /= cv.confidence_plot - %hr + %div.row{:style=>"background-color:#f5f5f5;"} + - model.crossvalidations.each do |crossvalidation| + %span.col-xs-4.col-sm-4.col-md-4.col-lg-4 + - cv = OpenTox::CrossValidation.find crossvalidation.id + = "Num folds:\t" + = cv.folds + %br + = "Num instances:\t" + = cv.nr_instances + %br + = "Num unpredicted" + = cv.nr_unpredicted + - if model.classification? + %br + = "Accuracy:\t" + = cv.accuracy.round(3) if cv.accuracy + %br + = "Weighted Accuracy:\t" + = cv.weighted_accuracy.round(3) if cv.weighted_accuracy + %br + = "True positive rate:\t" + = cv.true_rate["active"].round(3) if cv.true_rate["active"] + %br + = "True negative rate:\t" + = cv.true_rate["inactive"].round(3) if cv.true_rate["inactive"] + %br + = "Positive predictive value:\t" + = cv.predictivity["active"].round(3) if cv.predictivity["active"] + %br + = "Negative predictive value:\t" + = cv.predictivity["inactive"].round(3) if cv.predictivity["inactive"] + %p + %b Confusion Matrix: + %table.table.table-condensed.table-borderless{:style=>"width:20%;"} + %tbody + %tr + %td + %td + %td + %b actual + %td + %td + %tr + %td + %td + %td active + %td inactive + %td total + %tr + %td + %b predicted + %td active + %td + =cv.confusion_matrix[0][0] + %td + =cv.confusion_matrix[0][1] + %td + =cv.confusion_matrix[0][0]+cv.confusion_matrix[0][1] + %tr + %td + %td inactive + %td + =cv.confusion_matrix[1][0] + %td + =cv.confusion_matrix[1][1] + %td + =cv.confusion_matrix[1][0]+cv.confusion_matrix[1][1] + -#%tr + %td + %td total + %td + =cv.confusion_matrix[0][0]+cv.confusion_matrix[1][0] + %td + =cv.confusion_matrix[0][1]+cv.confusion_matrix[1][1] + %td + -#= "Confusion Matrix:\t" + -#= cv.confusion_matrix + - if model.regression? + %br + = "Root mean squared error:\t" + = cv.rmse.round(3) if cv.rmse + %br + = "Weighted root mean squared error:\t" + = cv.weighted_rmse.round(3) if cv.weighted_rmse + %br + = "Mean absolute error:\t" + = cv.mae.round(3) if cv.mae + %br + = "Weighted mean absolute error:\t" + = cv.weighted_mae.round(3) if cv.weighted_mae + %br + = "R square:\t" + = cv.r_squared.round(3) if cv.r_squared + /%br + /= "Correlation plot" + /= cv.correlation_plot + /%br + /= "Confidence plot:" + /= cv.confidence_plot %fieldset#bottom.well diff --git a/views/prediction.haml b/views/prediction.haml index e7bc88a..47bd9b7 100644 --- a/views/prediction.haml +++ b/views/prediction.haml @@ -22,6 +22,7 @@ %p= @compound.svg %p= @compound.smiles - @predictions.each_with_index do |prediction,i| + - type = @models[i].model.class.to_s.match("Classification") ? "Classification" : "Regression" %td{:style=>"vertical-align:top;"} %b{:class => "title"} = "#{@models[i].endpoint.gsub('_', ' ')} (#{@models[i].species})" @@ -30,23 +31,23 @@ %p / TODO fix scientific notation from database %b Measured activity: - = prediction[:value].numeric? ? "#{prediction[:value].to_f.round(3)} (#{@models[i].unit})" : prediction[:value] + = (type == "Regression") ? "#{prediction[:value].round(2)} (#{@models[i].unit})" : prediction[:value] %p Compound is part of the training dataset - elsif prediction[:neighbors].size > 0 %p / model type (classification|regression) %b Type: - = @models[i].model.class.to_s.match("Classification") ? "Classification" : "Regression" + = type %br %b Prediction: / TODO scientific notation - = prediction[:value].numeric? ? "#{'%.2e' % prediction[:value]} #{@models[i].unit}" : prediction[:value] + = (type == "Regression") ? "#{'%.2e' % prediction[:value]} #{@models[i].unit}" : prediction[:value] / TODO update description / %a.btn.glyphicon.glyphicon-info-sign{:href=>"#", :title=>"Prediction", data: {toggle:"popover", placement:"left", html:"true", content:"LAZAR calculates searches the training dataset for similar compounds (neighbors) and calculates the prediction from their measured activities. LAZAR calculates predictions using <ul><li>a majority vote (weighted by compound similarity) for<br /><b>classification</b> (<a href='http://www.frontiersin.org/Journal/10.3389/fphar.2013.00038/abstract', target='_blank'>original publication</a>) </li><li>a local QSAR model based on neighbors for<br /><b>regression</b> (<a href='http://www.frontiersin.org/Journal/10.3389/fphar.2013.00038/abstract', target='_blank'</h>original publication</a>) </li></ul>Please keep in mind that predictions are based on the measured activities of neighbors."}} %br / TODO probability %b Confidence: - = prediction[:confidence].round(3) + = prediction[:confidence].round(2) / %a.btn.glyphicon.glyphicon-info-sign{:href=>"#", :title=>"Confidence", data: {toggle:"popover", placement:"left", html:"true", content:"Indicates the applicability domain of a model. Predictions with a high confidence can be expected to be more reliable than predictions with low confidence. Confidence values may take any value between 0 and 1. For most models confidence > 0.025 is a sensible (hard) cutoff to distinguish between reliable and unreliable predictions."}} %p /TODO add tooltip for significant ftagments and descriptors |