diff 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
line wrap: on
line diff
--- a/estimator_attributes.xml	Tue Jul 09 19:32:22 2019 -0400
+++ b/estimator_attributes.xml	Fri Aug 09 07:24:14 2019 -0400
@@ -30,8 +30,7 @@
 from imblearn.pipeline import Pipeline as imbPipeline
 from sklearn.pipeline import Pipeline
 
-sys.path.insert(0, '$__tool_directory__')
-from utils import load_model, get_search_params
+from galaxy_ml.utils import load_model, get_search_params
 
 warnings.simplefilter('ignore')
 
@@ -51,7 +50,7 @@
     print(repr(res))
     with open('$outfile', 'wb') as f:
         pickle.dump(res, f, pickle.HIGHEST_PROTOCOL)
-elif attribute in ['best_estimator_', 'init_']:
+elif attribute in ['best_estimator_', 'init_', 'classifier_', 'regressor_']:
     res = getattr(est_obj, attribute)
     print(repr(res))
     with open('$outfile', 'wb') as f:
@@ -68,8 +67,13 @@
     res = pandas.DataFrame(est_obj.cv_results_)
     res = res[sorted(res.columns)]
     res.to_csv('$outfile', sep='\t', index=False)
+elif attribute == 'save_weights':
+    est_obj.save_weights('$outfile')
 else:
-    res = getattr(est_obj, attribute)
+    if attribute == 'get_signature':
+        res = est_obj.get_signature()
+    else:
+        res = getattr(est_obj, attribute)
     columns = []
     if res.ndim == 1 or res.shape[-1] == 1:
         columns = [attribute]
@@ -91,6 +95,9 @@
             <option value="train_score_">Fitted estimator - train_score_ </option>
             <option value="oob_score_">Fitted estimator - oob_score_ </option>
             <option value="init_">Fitted estimator - init_ </option>
+            <option value="classifier_">Fitted BinarizeTargetClassifier - classifier_</option>
+            <option value="regressor_">Fitted BinarizeTargetRegressor - regressor_</option>
+            <option value="get_signature">Fitted IRAPSClassifier - get_signature</option>
             <option value="named_steps">Pipeline - named_steps </option>
             <option value="final_estimator">Pipeline - final_estimator </option>
             <option value="cv_results_">SearchCV - cv_results_ </option>
@@ -102,6 +109,7 @@
             <option value="ranking_">Feature_selection - ranking_ </option>
             <option value="n_features_">Feature_selection - n_features_ </option>
             <option value="grid_scores_">Feature_selection - grid_scores_ </option>
+            <option value="save_weights">KerasGClassifier/KerasGRegressor - save_weights</option>
         </param>
     </inputs>
     <outputs>
@@ -112,6 +120,9 @@
                 <when input="attribute_type" value="final_estimator" format="zip" />
                 <when input="attribute_type" value="best_estimator_" format="zip" />
                 <when input="attribute_type" value="init_" format="zip" />
+                <when input="attribute_type" value="classifier_" format="zip" />
+                <when input="attribute_type" value="regressor_" format="zip" />
+                <when input="attribute_type" value="save_weights" format="h5"/>
             </change_format>
         </data>
     </outputs>
@@ -156,6 +167,11 @@
             <param name="attribute_type" value="get_params"/>
             <output name="outfile" value="get_params.tabular"/>
         </test>
+        <test>
+            <param name="infile_object" value="fitted_keras_g_regressor01.zip" ftype="zip"/>
+            <param name="attribute_type" value="save_weights"/>
+            <output name="outfile" value="keras_save_weights01.h5" compare="sim_size" delta="5"/>
+        </test>
     </tests>
     <help>
         <![CDATA[