comparison estimator_attributes.xml @ 2:c411ff569a26 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 60f0fbc0eafd7c11bc60fb6c77f2937782efd8a9-dirty
author bgruening
date Fri, 09 Aug 2019 07:24:14 -0400
parents 2ad4c2798be7
children 27fabe5feedc
comparison
equal deleted inserted replaced
1:84ddbf61e107 2:c411ff569a26
28 model_selection, naive_bayes, neighbors, pipeline, preprocessing, 28 model_selection, naive_bayes, neighbors, pipeline, preprocessing,
29 svm, linear_model, tree, discriminant_analysis) 29 svm, linear_model, tree, discriminant_analysis)
30 from imblearn.pipeline import Pipeline as imbPipeline 30 from imblearn.pipeline import Pipeline as imbPipeline
31 from sklearn.pipeline import Pipeline 31 from sklearn.pipeline import Pipeline
32 32
33 sys.path.insert(0, '$__tool_directory__') 33 from galaxy_ml.utils import load_model, get_search_params
34 from utils import load_model, get_search_params
35 34
36 warnings.simplefilter('ignore') 35 warnings.simplefilter('ignore')
37 36
38 infile_object = '$infile_object' 37 infile_object = '$infile_object'
39 attribute = '$attribute_type' 38 attribute = '$attribute_type'
49 elif attribute == 'final_estimator': 48 elif attribute == 'final_estimator':
50 res = est_obj.steps[-1][-1] 49 res = est_obj.steps[-1][-1]
51 print(repr(res)) 50 print(repr(res))
52 with open('$outfile', 'wb') as f: 51 with open('$outfile', 'wb') as f:
53 pickle.dump(res, f, pickle.HIGHEST_PROTOCOL) 52 pickle.dump(res, f, pickle.HIGHEST_PROTOCOL)
54 elif attribute in ['best_estimator_', 'init_']: 53 elif attribute in ['best_estimator_', 'init_', 'classifier_', 'regressor_']:
55 res = getattr(est_obj, attribute) 54 res = getattr(est_obj, attribute)
56 print(repr(res)) 55 print(repr(res))
57 with open('$outfile', 'wb') as f: 56 with open('$outfile', 'wb') as f:
58 pickle.dump(res, f, pickle.HIGHEST_PROTOCOL) 57 pickle.dump(res, f, pickle.HIGHEST_PROTOCOL)
59 elif attribute in ['oob_score_', 'best_score_', 'n_features_']: 58 elif attribute in ['oob_score_', 'best_score_', 'n_features_']:
66 f.write(repr(res)) 65 f.write(repr(res))
67 elif attribute == 'cv_results_': 66 elif attribute == 'cv_results_':
68 res = pandas.DataFrame(est_obj.cv_results_) 67 res = pandas.DataFrame(est_obj.cv_results_)
69 res = res[sorted(res.columns)] 68 res = res[sorted(res.columns)]
70 res.to_csv('$outfile', sep='\t', index=False) 69 res.to_csv('$outfile', sep='\t', index=False)
70 elif attribute == 'save_weights':
71 est_obj.save_weights('$outfile')
71 else: 72 else:
72 res = getattr(est_obj, attribute) 73 if attribute == 'get_signature':
74 res = est_obj.get_signature()
75 else:
76 res = getattr(est_obj, attribute)
73 columns = [] 77 columns = []
74 if res.ndim == 1 or res.shape[-1] == 1: 78 if res.ndim == 1 or res.shape[-1] == 1:
75 columns = [attribute] 79 columns = [attribute]
76 else: 80 else:
77 for i in range(res.shape[-1]): 81 for i in range(res.shape[-1]):
89 <option value="feature_importances_" >Fitted estimator - feature_importances_ </option> 93 <option value="feature_importances_" >Fitted estimator - feature_importances_ </option>
90 <option value="coef_">Fitted estimator - coef_ </option> 94 <option value="coef_">Fitted estimator - coef_ </option>
91 <option value="train_score_">Fitted estimator - train_score_ </option> 95 <option value="train_score_">Fitted estimator - train_score_ </option>
92 <option value="oob_score_">Fitted estimator - oob_score_ </option> 96 <option value="oob_score_">Fitted estimator - oob_score_ </option>
93 <option value="init_">Fitted estimator - init_ </option> 97 <option value="init_">Fitted estimator - init_ </option>
98 <option value="classifier_">Fitted BinarizeTargetClassifier - classifier_</option>
99 <option value="regressor_">Fitted BinarizeTargetRegressor - regressor_</option>
100 <option value="get_signature">Fitted IRAPSClassifier - get_signature</option>
94 <option value="named_steps">Pipeline - named_steps </option> 101 <option value="named_steps">Pipeline - named_steps </option>
95 <option value="final_estimator">Pipeline - final_estimator </option> 102 <option value="final_estimator">Pipeline - final_estimator </option>
96 <option value="cv_results_">SearchCV - cv_results_ </option> 103 <option value="cv_results_">SearchCV - cv_results_ </option>
97 <option value="best_estimator_">SearchCV - best_estimator_ </option> 104 <option value="best_estimator_">SearchCV - best_estimator_ </option>
98 <option value="best_score_">SearchCV - best_score_ </option> 105 <option value="best_score_">SearchCV - best_score_ </option>
100 <option value="scores_">Feature_selection - scores_ </option> 107 <option value="scores_">Feature_selection - scores_ </option>
101 <option value="pvalues_">Feature_selection - pvalues_ </option> 108 <option value="pvalues_">Feature_selection - pvalues_ </option>
102 <option value="ranking_">Feature_selection - ranking_ </option> 109 <option value="ranking_">Feature_selection - ranking_ </option>
103 <option value="n_features_">Feature_selection - n_features_ </option> 110 <option value="n_features_">Feature_selection - n_features_ </option>
104 <option value="grid_scores_">Feature_selection - grid_scores_ </option> 111 <option value="grid_scores_">Feature_selection - grid_scores_ </option>
112 <option value="save_weights">KerasGClassifier/KerasGRegressor - save_weights</option>
105 </param> 113 </param>
106 </inputs> 114 </inputs>
107 <outputs> 115 <outputs>
108 <data format="tabular" name="outfile" label="${attribute_type} from ${on_string}"> 116 <data format="tabular" name="outfile" label="${attribute_type} from ${on_string}">
109 <change_format> 117 <change_format>
110 <when input="attribute_type" value="named_steps" format="txt" /> 118 <when input="attribute_type" value="named_steps" format="txt" />
111 <when input="attribute_type" value="best_params_" format="txt" /> 119 <when input="attribute_type" value="best_params_" format="txt" />
112 <when input="attribute_type" value="final_estimator" format="zip" /> 120 <when input="attribute_type" value="final_estimator" format="zip" />
113 <when input="attribute_type" value="best_estimator_" format="zip" /> 121 <when input="attribute_type" value="best_estimator_" format="zip" />
114 <when input="attribute_type" value="init_" format="zip" /> 122 <when input="attribute_type" value="init_" format="zip" />
123 <when input="attribute_type" value="classifier_" format="zip" />
124 <when input="attribute_type" value="regressor_" format="zip" />
125 <when input="attribute_type" value="save_weights" format="h5"/>
115 </change_format> 126 </change_format>
116 </data> 127 </data>
117 </outputs> 128 </outputs>
118 <tests> 129 <tests>
119 <test> 130 <test>
154 <test> 165 <test>
155 <param name="infile_object" value="LinearRegression02.zip" ftype="zip"/> 166 <param name="infile_object" value="LinearRegression02.zip" ftype="zip"/>
156 <param name="attribute_type" value="get_params"/> 167 <param name="attribute_type" value="get_params"/>
157 <output name="outfile" value="get_params.tabular"/> 168 <output name="outfile" value="get_params.tabular"/>
158 </test> 169 </test>
170 <test>
171 <param name="infile_object" value="fitted_keras_g_regressor01.zip" ftype="zip"/>
172 <param name="attribute_type" value="save_weights"/>
173 <output name="outfile" value="keras_save_weights01.h5" compare="sim_size" delta="5"/>
174 </test>
159 </tests> 175 </tests>
160 <help> 176 <help>
161 <![CDATA[ 177 <![CDATA[
162 **What it does** 178 **What it does**
163 Output attribute from an estimator or any scikit object. 179 Output attribute from an estimator or any scikit object.