Mercurial > repos > bgruening > nn_classifier
comparison nn_classifier.xml @ 5:25a68adb2ade draft
planemo upload for repository https://github.com/bgruening/galaxytools/tools/sklearn commit 0e582cf1f3134c777cce3aa57d71b80ed95e6ba9
author | bgruening |
---|---|
date | Fri, 16 Feb 2018 09:13:21 -0500 |
parents | 4354c286f7a7 |
children | c64f57fe1b97 |
comparison
equal
deleted
inserted
replaced
4:c85acc0197c6 | 5:25a68adb2ade |
---|---|
31 | 31 |
32 data = pandas.read_csv("$selected_tasks.infile_data", sep='\t', header=0, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False ) | 32 data = pandas.read_csv("$selected_tasks.infile_data", sep='\t', header=0, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False ) |
33 prediction = classifier_object.predict(data) | 33 prediction = classifier_object.predict(data) |
34 prediction_df = pandas.DataFrame(prediction) | 34 prediction_df = pandas.DataFrame(prediction) |
35 res = pandas.concat([data, prediction_df], axis=1) | 35 res = pandas.concat([data, prediction_df], axis=1) |
36 res.to_csv(path_or_buf = "$outfile", sep="\t", index=False) | 36 res.to_csv(path_or_buf = "$outfile_predict", sep="\t", index=False) |
37 | 37 |
38 #else: | 38 #else: |
39 | 39 |
40 data_train = pandas.read_csv("$selected_tasks.infile_train", sep='\t', header=0, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False ) | 40 data_train = pandas.read_csv("$selected_tasks.infile_train", sep='\t', header=0, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False ) |
41 | 41 |
55 | 55 |
56 my_class = getattr(sklearn.neighbors, classifier) | 56 my_class = getattr(sklearn.neighbors, classifier) |
57 classifier_object = my_class(**options) | 57 classifier_object = my_class(**options) |
58 classifier_object.fit(data,labels) | 58 classifier_object.fit(data,labels) |
59 | 59 |
60 pickle.dump(classifier_object,open("$outfile", 'w+')) | 60 pickle.dump(classifier_object,open("$outfile_fit", 'w+')) |
61 | 61 |
62 #end if | 62 #end if |
63 | 63 |
64 ]]> | 64 ]]> |
65 </configfile> | 65 </configfile> |
66 </configfiles> | 66 </configfiles> |
67 <inputs> | 67 <inputs> |
68 <expand macro="train_loadConditional"><!--Todo: add sparse to targets--> | 68 <expand macro="train_loadConditional" model="zip"><!--Todo: add sparse to targets--> |
69 <param name="selected_algorithm" type="select" label="Classifier type"> | 69 <param name="selected_algorithm" type="select" label="Classifier type"> |
70 <option value="nneighbors">Nearest Neighbors</option> | 70 <option value="nneighbors">Nearest Neighbors</option> |
71 <option value="ncentroid">Nearest Centroid</option> | 71 <option value="ncentroid">Nearest Centroid</option> |
72 </param> | 72 </param> |
73 <when value="nneighbors"> | 73 <when value="nneighbors"> |
81 <param argument="n_neighbors" type="integer" optional="true" value="5" label="Number of neighbors" help=" "/> | 81 <param argument="n_neighbors" type="integer" optional="true" value="5" label="Number of neighbors" help=" "/> |
82 </expand> | 82 </expand> |
83 </when> | 83 </when> |
84 <when value="RadiusNeighborsClassifier"> | 84 <when value="RadiusNeighborsClassifier"> |
85 <expand macro="nn_advanced_options"> | 85 <expand macro="nn_advanced_options"> |
86 <param argument="radius" type="float" optional="true" value="1.0" label="Radius" help="Range of parameter space to use by default for :meth ''radius_neighbors'' queries."/> | 86 <param argument="radius" type="float" optional="true" value="1.0" label="Radius" |
87 help="Range of parameter space to use by default for :meth ''radius_neighbors'' queries."/> | |
87 </expand> | 88 </expand> |
88 </when> | 89 </when> |
89 </conditional> | 90 </conditional> |
90 </when> | 91 </when> |
91 <when value="ncentroid"> | 92 <when value="ncentroid"> |
92 <section name="options" title="Advanced Options" expanded="False"> | 93 <section name="options" title="Advanced Options" expanded="False"> |
93 <param argument="metric" type="text" optional="true" value="euclidean" label="Metric" help="The metric to use when calculating distance between instances in a feature array."/> | 94 <param argument="metric" type="text" optional="true" value="euclidean" label="Metric" |
94 <param argument="shrink_threshold" type="float" optional="true" value="" label="Shrink threshold" help="Floating point number for shrinking centroids to remove features."/> | 95 help="The metric to use when calculating distance between instances in a feature array."/> |
96 <param argument="shrink_threshold" type="float" optional="true" value="" label="Shrink threshold" | |
97 help="Floating point number for shrinking centroids to remove features."/> | |
95 </section> | 98 </section> |
96 </when> | 99 </when> |
97 </expand> | 100 </expand> |
98 </inputs> | 101 </inputs> |
99 <outputs> | 102 |
100 <data format="txt" name="outfile"/> | 103 <expand macro="output"/> |
101 </outputs> | 104 |
102 <tests> | 105 <tests> |
103 <test> | 106 <test> |
104 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> | 107 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> |
105 <param name="selected_task" value="train"/> | 108 <param name="selected_task" value="train"/> |
106 <param name="selected_algorithm" value="nneighbors"/> | 109 <param name="selected_algorithm" value="nneighbors"/> |
107 <param name="sampling_method" value="KNeighborsClassifier" /> | 110 <param name="sampling_method" value="KNeighborsClassifier" /> |
108 <param name="algorithm" value="brute" /> | 111 <param name="algorithm" value="brute" /> |
109 <output name="outfile" file="nn_model01.txt"/> | 112 <output name="outfile_fit" file="nn_model01.txt"/> |
110 </test> | 113 </test> |
111 <test> | 114 <test> |
112 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> | 115 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> |
113 <param name="selected_task" value="train"/> | 116 <param name="selected_task" value="train"/> |
114 <param name="selected_algorithm" value=""/> | 117 <param name="selected_algorithm" value=""/> |
115 <param name="selected_algorithm" value="nneighbors"/> | 118 <param name="selected_algorithm" value="nneighbors"/> |
116 <param name="sampling_method" value="RadiusNeighborsClassifier" /> | 119 <param name="sampling_method" value="RadiusNeighborsClassifier" /> |
117 <output name="outfile" file="nn_model02.txt"/> | 120 <output name="outfile_fit" file="nn_model02.txt"/> |
118 </test> | 121 </test> |
119 <test> | 122 <test> |
120 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> | 123 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> |
121 <param name="selected_task" value="train"/> | 124 <param name="selected_task" value="train"/> |
122 <param name="selected_algorithm" value="ncentroid"/> | 125 <param name="selected_algorithm" value="ncentroid"/> |
123 <output name="outfile" file="nn_model03.txt"/> | 126 <output name="outfile_fit" file="nn_model03.txt"/> |
124 </test> | 127 </test> |
125 <test> | 128 <test> |
126 <param name="infile_model" value="nn_model01.txt" ftype="txt"/> | 129 <param name="infile_model" value="nn_model01.txt" ftype="txt"/> |
127 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> | 130 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> |
128 <param name="selected_task" value="load"/> | 131 <param name="selected_task" value="load"/> |
129 <output name="outfile" file="nn_prediction_result01.tabular"/> | 132 <output name="outfile_predict" file="nn_prediction_result01.tabular"/> |
130 </test> | 133 </test> |
131 <test> | 134 <test> |
132 <param name="infile_model" value="nn_model02.txt" ftype="txt"/> | 135 <param name="infile_model" value="nn_model02.txt" ftype="txt"/> |
133 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> | 136 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> |
134 <param name="selected_task" value="load"/> | 137 <param name="selected_task" value="load"/> |
135 <output name="outfile" file="nn_prediction_result02.tabular"/> | 138 <output name="outfile_predict" file="nn_prediction_result02.tabular"/> |
136 </test> | 139 </test> |
137 <test> | 140 <test> |
138 <param name="infile_model" value="nn_model03.txt" ftype="txt"/> | 141 <param name="infile_model" value="nn_model03.txt" ftype="txt"/> |
139 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> | 142 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> |
140 <param name="selected_task" value="load"/> | 143 <param name="selected_task" value="load"/> |
141 <output name="outfile" file="nn_prediction_result03.tabular"/> | 144 <output name="outfile_predict" file="nn_prediction_result03.tabular"/> |
142 </test> | 145 </test> |
143 </tests> | 146 </tests> |
144 <help><![CDATA[ | 147 <help><![CDATA[ |
145 **What it does** | 148 **What it does** |
146 This module implements the k-nearest neighbors classification algorithms. | 149 This module implements the k-nearest neighbors classification algorithms. |