Mercurial > repos > bgruening > svm_classifier
comparison svm.xml @ 5:86eb3864c899 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tools/sklearn commit 0e582cf1f3134c777cce3aa57d71b80ed95e6ba9
author | bgruening |
---|---|
date | Fri, 16 Feb 2018 09:12:19 -0500 |
parents | 4f1b0620ea89 |
children | b70724d5445e |
comparison
equal
deleted
inserted
replaced
4:d5cdb4f35e03 | 5:86eb3864c899 |
---|---|
1 <tool id="svm_classifier" name="Support vector machines (SVMs)" version="@VERSION@"> | 1 <tool id="svm_classifier" name="Support vector machines (SVMs)" version="@VERSION@"> |
2 <description>for classification</description> | 2 <description>for classification</description> |
3 <expand macro="python_requirements"/> | |
4 <expand macro="macro_stdio"/> | |
5 <macros> | 3 <macros> |
6 <import>main_macros.xml</import> | 4 <import>main_macros.xml</import> |
7 <!-- macro name="class_weight" argument="class_weight"--> | 5 <!-- macro name="class_weight" argument="class_weight"--> |
8 </macros> | 6 </macros> |
7 <expand macro="python_requirements"/> | |
8 <expand macro="macro_stdio"/> | |
9 <version_command>echo "@VERSION@"</version_command> | 9 <version_command>echo "@VERSION@"</version_command> |
10 <command><![CDATA[ | 10 <command><![CDATA[ |
11 python "$svc_script" '$inputs' | 11 python "$svc_script" '$inputs' |
12 ]]> | 12 ]]> |
13 </command> | 13 </command> |
25 input_json_path = sys.argv[1] | 25 input_json_path = sys.argv[1] |
26 params = json.load(open(input_json_path, "r")) | 26 params = json.load(open(input_json_path, "r")) |
27 | 27 |
28 #if $selected_tasks.selected_task == "load": | 28 #if $selected_tasks.selected_task == "load": |
29 | 29 |
30 classifier_object = pickle.load(open("$infile_model", 'r')) | 30 classifier_object = pickle.load(open("$infile_model", 'rb')) |
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 |
51 | 51 |
52 my_class = getattr(sklearn.svm, selected_algorithm) | 52 my_class = getattr(sklearn.svm, selected_algorithm) |
53 classifier_object = my_class(**options) | 53 classifier_object = my_class(**options) |
54 classifier_object.fit(data,labels) | 54 classifier_object.fit(data,labels) |
55 | 55 |
56 pickle.dump(classifier_object,open("$outfile", 'w+')) | 56 pickle.dump(classifier_object,open("$outfile_fit", 'w+')) |
57 | 57 |
58 #end if | 58 #end if |
59 | 59 |
60 ]]> | 60 ]]> |
61 </configfile> | 61 </configfile> |
62 </configfiles> | 62 </configfiles> |
63 <inputs> | 63 <inputs> |
64 <expand macro="train_loadConditional"> | 64 <expand macro="train_loadConditional" model="zip"> |
65 <param name="selected_algorithm" type="select" label="Classifier type"> | 65 <param name="selected_algorithm" type="select" label="Classifier type"> |
66 <option value="SVC">C-Support Vector Classification</option> | 66 <option value="SVC">C-Support Vector Classification</option> |
67 <option value="NuSVC">Nu-Support Vector Classification</option> | 67 <option value="NuSVC">Nu-Support Vector Classification</option> |
68 <option value="LinearSVC">Linear Support Vector Classification</option> | 68 <option value="LinearSVC">Linear Support Vector Classification</option> |
69 </param> | 69 </param> |
101 <param argument="intercept_scaling" type="float" optional="true" value="1" label="Add synthetic feature to the instance vector" help=" "/> | 101 <param argument="intercept_scaling" type="float" optional="true" value="1" label="Add synthetic feature to the instance vector" help=" "/> |
102 </section> | 102 </section> |
103 </when> | 103 </when> |
104 </expand> | 104 </expand> |
105 </inputs> | 105 </inputs> |
106 <outputs> | 106 |
107 <data format="txt" name="outfile"/> | 107 <expand macro="output"/> |
108 </outputs> | 108 |
109 <tests> | 109 <tests> |
110 <test> | 110 <test> |
111 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> | 111 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> |
112 <param name="selected_task" value="train"/> | 112 <param name="selected_task" value="train"/> |
113 <param name="selected_algorithm" value="SVC"/> | 113 <param name="selected_algorithm" value="SVC"/> |
114 <param name="random_state" value="5"/> | 114 <param name="random_state" value="5"/> |
115 <output name="outfile" file="svc_model01.txt"/> | 115 <output name="outfile_fit" file="svc_model01.txt"/> |
116 </test> | 116 </test> |
117 <test> | 117 <test> |
118 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> | 118 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> |
119 <param name="selected_task" value="train"/> | 119 <param name="selected_task" value="train"/> |
120 <param name="selected_algorithm" value="NuSVC"/> | 120 <param name="selected_algorithm" value="NuSVC"/> |
121 <param name="random_state" value="5"/> | 121 <param name="random_state" value="5"/> |
122 <output name="outfile" file="svc_model02.txt"/> | 122 <output name="outfile_fit" file="svc_model02.txt"/> |
123 </test> | 123 </test> |
124 <test> | 124 <test> |
125 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> | 125 <param name="infile_train" value="train_set.tabular" ftype="tabular"/> |
126 <param name="selected_task" value="train"/> | 126 <param name="selected_task" value="train"/> |
127 <param name="selected_algorithm" value="LinearSVC"/> | 127 <param name="selected_algorithm" value="LinearSVC"/> |
128 <param name="random_state" value="5"/> | 128 <param name="random_state" value="5"/> |
129 <output name="outfile" file="svc_model03.txt"/> | 129 <output name="outfile_fit" file="svc_model03.txt"/> |
130 </test> | 130 </test> |
131 <test> | 131 <test> |
132 <param name="infile_model" value="svc_model01.txt" ftype="txt"/> | 132 <param name="infile_model" value="svc_model01.txt" ftype="txt"/> |
133 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> | 133 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> |
134 <param name="selected_task" value="load"/> | 134 <param name="selected_task" value="load"/> |
135 <output name="outfile" file="svc_prediction_result01.tabular"/> | 135 <output name="outfile_predict" file="svc_prediction_result01.tabular"/> |
136 </test> | 136 </test> |
137 <test> | 137 <test> |
138 <param name="infile_model" value="svc_model02.txt" ftype="txt"/> | 138 <param name="infile_model" value="svc_model02.txt" ftype="txt"/> |
139 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> | 139 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> |
140 <param name="selected_task" value="load"/> | 140 <param name="selected_task" value="load"/> |
141 <output name="outfile" file="svc_prediction_result02.tabular"/> | 141 <output name="outfile_predict" file="svc_prediction_result02.tabular"/> |
142 </test> | 142 </test> |
143 <test> | 143 <test> |
144 <param name="infile_model" value="svc_model03.txt" ftype="txt"/> | 144 <param name="infile_model" value="svc_model03.txt" ftype="txt"/> |
145 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> | 145 <param name="infile_data" value="test_set.tabular" ftype="tabular"/> |
146 <param name="selected_task" value="load"/> | 146 <param name="selected_task" value="load"/> |
147 <output name="outfile" file="svc_prediction_result03.tabular"/> | 147 <output name="outfile_predict" file="svc_prediction_result03.tabular"/> |
148 </test> | 148 </test> |
149 </tests> | 149 </tests> |
150 <help><![CDATA[ | 150 <help><![CDATA[ |
151 **What it does** | 151 **What it does** |
152 This module implements the Support Vector Machine (SVM) classification algorithms. | 152 This module implements the Support Vector Machine (SVM) classification algorithms. |