comparison regression_metrics.xml @ 0:ca05b5889dfc draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2e1e78576b38110cf5b1f2ed83b08b9c3a6cbfee
author bgruening
date Sat, 28 Apr 2018 18:05:04 -0400
parents
children c5feb1a67e9b
comparison
equal deleted inserted replaced
-1:000000000000 0:ca05b5889dfc
1 <tool id="sklearn_regression_metrics" name="Calculate metrics" version="@VERSION@">
2 <description>for regression performance</description>
3 <macros>
4 <import>main_macros.xml</import>
5 </macros>
6 <expand macro="python_requirements"/>
7 <expand macro="macro_stdio"/>
8 <version_command>echo "@VERSION@"</version_command>
9 <command>
10 <![CDATA[
11 python "$regression_metrics_script" '$inputs'
12 ]]>
13 </command>
14 <configfiles>
15 <inputs name="inputs" />
16 <configfile name="regression_metrics_script">
17 <![CDATA[
18 import sys
19 import json
20 import pandas
21 import numpy as np
22 from sklearn import metrics
23
24 @COLUMNS_FUNCTION@
25
26 input_json_path = sys.argv[1]
27 params = json.load(open(input_json_path, "r"))
28
29 header='infer' if params["regression_metrics"]["header1"] else None
30 y_t = read_columns(
31 "$regression_metrics.infile1",
32 "$regression_metrics.col1",
33 sep='\t',
34 header=header,
35 parse_dates=True
36 )
37
38 header='infer' if params["regression_metrics"]["header2"] else None
39 y_p = read_columns(
40 "$regression_metrics.infile2",
41 "$regression_metrics.col2",
42 sep='\t',
43 header=header,
44 parse_dates=True
45 )
46
47 options = params["regression_metrics"].get("options", {})
48 if options and options.get('average', '') == 'None':
49 options['average'] = None
50 metric = params["regression_metrics"]["selected_metric"]
51 metric_function = getattr(metrics, metric)
52 res = metric_function(y_t,y_p,**options)
53 res= format(res, '.4f')
54 with open("$outfile", 'w+') as out_file:
55 out_file.write( metric + ' : ' + '\n' + str(res) + '\n' )
56
57 ]]>
58 </configfile>
59 </configfiles>
60 <inputs>
61 <conditional name="regression_metrics">
62 <param name="selected_metric" type="select" label="Metrics">
63 <option value="explained_variance_score" selected="true">explained_variance_score - Explained variance regression score function</option>
64 <option value="mean_absolute_error">mean_absolute_error - Mean absolute error regression loss</option>
65 <option value="mean_squared_error">mean_squared_error - Mean squared error regression loss</option>
66 <option value="mean_squared_log_error">mean_squared_log_error - Mean squared logarithmic error regression loss</option>
67 <option value="median_absolute_error">median_absolute_error - Median absolute error regression loss</option>
68 <option value="r2_score">r2_score - R^2 (coefficient of determination) regression score function</option>
69 </param>
70 <when value="explained_variance_score">
71 <expand macro="clf_inputs"/>
72 <!--section name="options" title="Advanced Options" expanded="False">
73 <!- -sample_weight- ->
74 <!- -multioutput- ->
75 </section-->
76 </when>
77 <when value="mean_absolute_error">
78 <expand macro="clf_inputs"/>
79 <!--section name="options" title="Advanced Options" expanded="False">
80 <!- -sample_weight- ->
81 <!- -multioutput- ->
82 </section-->
83 </when>
84 <when value="mean_squared_error">
85 <expand macro="clf_inputs"/>
86 <!--section name="options" title="Advanced Options" expanded="False">
87 <!- -sample_weight- ->
88 <!- -multioutput- ->
89 </section-->
90 </when>
91 <when value="mean_squared_log_error">
92 <expand macro="clf_inputs"/>
93 <!--section name="options" title="Advanced Options" expanded="False">
94 <!- -sample_weight- ->
95 <!- -multioutput- ->
96 </section-->
97 </when>
98 <when value="median_absolute_error">
99 <expand macro="clf_inputs"/>
100 </when>
101 <when value="r2_score">
102 <expand macro="clf_inputs"/>
103 <!--section name="options" title="Advanced Options" expanded="False">
104 <!- -sample_weight- ->
105 <!- -multioutput- ->
106 </section-->
107 </when>
108 </conditional>
109 </inputs>
110 <outputs>
111 <data format="txt" name="outfile"/>
112 </outputs>
113 <tests>
114 <test>
115 <param name="selected_metric" value="explained_variance_score"/>
116 <param name="infile1" value="regression_test_y.tabular" ftype="tabular"/>
117 <param name="header1" value="True"/>
118 <param name="col1" value="1"/>
119 <param name="infile2" value="regression_test_y.tabular" ftype="tabular"/>
120 <param name="header2" value="True"/>
121 <param name="col2" value="2"/>
122 <output name="outfile" file="regression_metrics_result01"/>
123 </test>
124 <test>
125 <param name="selected_metric" value="mean_absolute_error"/>
126 <param name="infile1" value="regression_test_y.tabular" ftype="tabular"/>
127 <param name="header1" value="True"/>
128 <param name="col1" value="1"/>
129 <param name="infile2" value="regression_test_y.tabular" ftype="tabular"/>
130 <param name="header2" value="True"/>
131 <param name="col2" value="2"/>
132 <output name="outfile" file="regression_metrics_result02"/>
133 </test>
134 <test>
135 <param name="selected_metric" value="mean_squared_error"/>
136 <param name="infile1" value="regression_test_y.tabular" ftype="tabular"/>
137 <param name="header1" value="True"/>
138 <param name="col1" value="1"/>
139 <param name="infile2" value="regression_test_y.tabular" ftype="tabular"/>
140 <param name="header2" value="True"/>
141 <param name="col2" value="2"/>
142 <output name="outfile" file="regression_metrics_result03"/>
143 </test>
144 <test>
145 <param name="selected_metric" value="mean_squared_log_error"/>
146 <param name="infile1" value="regression_test_y.tabular" ftype="tabular"/>
147 <param name="header1" value="True"/>
148 <param name="col1" value="1"/>
149 <param name="infile2" value="regression_test_y.tabular" ftype="tabular"/>
150 <param name="header2" value="True"/>
151 <param name="col2" value="2"/>
152 <output name="outfile" file="regression_metrics_result04"/>
153 </test>
154 <test>
155 <param name="selected_metric" value="median_absolute_error"/>
156 <param name="infile1" value="regression_test_y.tabular" ftype="tabular"/>
157 <param name="header1" value="True"/>
158 <param name="col1" value="1"/>
159 <param name="infile2" value="regression_test_y.tabular" ftype="tabular"/>
160 <param name="header2" value="True"/>
161 <param name="col2" value="2"/>
162 <output name="outfile" file="regression_metrics_result05"/>
163 </test>
164 <test>
165 <param name="selected_metric" value="r2_score"/>
166 <param name="infile1" value="regression_test_y.tabular" ftype="tabular"/>
167 <param name="header1" value="True"/>
168 <param name="col1" value="1"/>
169 <param name="infile2" value="regression_test_y.tabular" ftype="tabular"/>
170 <param name="header2" value="True"/>
171 <param name="col2" value="2"/>
172 <output name="outfile" file="regression_metrics_result06"/>
173 </test>
174 </tests>
175 <help>
176 <![CDATA[
177 **What it does**
178 This tool provides several loss, score, and utility functions to measure classification performance. Some metrics might require probability estimates of the positive class, confidence values, or binary decisions values. This tool is based on
179 sklearn.metrics package.
180 For information about classification metric functions and their parameter settings please refer to `Scikit-learn classification metrics`_.
181
182 .. _`Scikit-learn classification metrics`: http://scikit-learn.org/stable/modules/model_evaluation.html#classification-metrics
183 ]]>
184 </help>
185 <expand macro="sklearn_citation"/>
186 </tool>