diff discriminant.xml @ 41:d769d83ec796 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
author bgruening
date Wed, 09 Aug 2023 13:14:12 +0000
parents eeaf989f1024
children
line wrap: on
line diff
--- a/discriminant.xml	Thu Aug 11 08:53:29 2022 +0000
+++ b/discriminant.xml	Wed Aug 09 13:14:12 2023 +0000
@@ -1,4 +1,4 @@
-<tool id="sklearn_discriminant_classifier" name="Discriminant Analysis" version="@VERSION@" profile="20.05">
+<tool id="sklearn_discriminant_classifier" name="Discriminant Analysis" version="@VERSION@" profile="@PROFILE@">
     <description></description>
     <macros>
         <import>main_macros.xml</import>
@@ -22,7 +22,8 @@
 import sklearn.discriminant_analysis
 import sys
 
-from galaxy_ml.utils import load_model, get_X_y
+from galaxy_ml.model_persist import dump_model_to_h5, load_model_from_h5
+from galaxy_ml.utils import clean_params, get_X_y
 
 
 input_json_path = sys.argv[1]
@@ -31,8 +32,8 @@
 
 #if $selected_tasks.selected_task == "load":
 
-with open("$infile_model", 'rb') as model_handler:
-    classifier_object = load_model(model_handler)
+classifier_object = load_model_from_h5('$infile_model')
+classifier_object = clean_params(classifier_object)
 
 header = 'infer' if params["selected_tasks"]["header"] else None
 data = pandas.read_csv("$selected_tasks.infile_data", sep='\t', header=header, index_col=None, parse_dates=True, encoding=None)
@@ -51,15 +52,14 @@
 my_class = getattr(sklearn.discriminant_analysis, selected_algorithm)
 classifier_object = my_class(**options)
 classifier_object.fit(X, y)
-with open("$outfile_fit", 'wb') as out_handler:
-    pickle.dump(classifier_object, out_handler, pickle.HIGHEST_PROTOCOL)
+dump_model_to_h5(classifier_object, '$outfile_fit')
 
 #end if
 ]]>
         </configfile>
     </configfiles>
     <inputs>
-        <expand macro="sl_Conditional" model="zip">
+        <expand macro="sl_Conditional" model="h5mlm">
             <param name="selected_algorithm" type="select" label="Classifier type">
                 <option value="LinearDiscriminantAnalysis" selected="true">Linear Discriminant Classifier</option>
                 <option value="QuadraticDiscriminantAnalysis">Quadratic Discriminant Classifier</option>
@@ -95,8 +95,6 @@
         <test>
             <param name="infile1" value="train.tabular" ftype="tabular" />
             <param name="infile2" value="train.tabular" ftype="tabular" />
-            <param name="header1" value="True" />
-            <param name="header2" value="True" />
             <param name="col1" value="1,2,3,4" />
             <param name="col2" value="5" />
             <param name="selected_task" value="train" />
@@ -108,8 +106,6 @@
         <test>
             <param name="infile1" value="train.tabular" ftype="tabular" />
             <param name="infile2" value="train.tabular" ftype="tabular" />
-            <param name="header1" value="True" />
-            <param name="header2" value="True" />
             <param name="col1" value="1,2,3,4" />
             <param name="col2" value="5" />
             <param name="selected_task" value="train" />
@@ -120,8 +116,6 @@
         <test>
             <param name="infile1" value="train.tabular" ftype="tabular" />
             <param name="infile2" value="train.tabular" ftype="tabular" />
-            <param name="header1" value="True" />
-            <param name="header2" value="True" />
             <param name="col1" value="1,2,3,4" />
             <param name="col2" value="5" />
             <param name="selected_task" value="train" />
@@ -129,23 +123,20 @@
             <output name="outfile_fit" file="qda_model01" compare="sim_size" delta="1" />
         </test>
         <test>
-            <param name="infile_model" value="lda_model01" ftype="zip" />
+            <param name="infile_model" value="lda_model01" ftype="h5mlm" />
             <param name="infile_data" value="test.tabular" ftype="tabular" />
-            <param name="header" value="True" />
             <param name="selected_task" value="load" />
             <output name="outfile_predict" file="lda_prediction_result01.tabular" />
         </test>
         <test>
-            <param name="infile_model" value="lda_model02" ftype="zip" />
+            <param name="infile_model" value="lda_model02" ftype="h5mlm" />
             <param name="infile_data" value="test.tabular" ftype="tabular" />
-            <param name="header" value="True" />
             <param name="selected_task" value="load" />
             <output name="outfile_predict" file="lda_prediction_result02.tabular" />
         </test>
         <test>
-            <param name="infile_model" value="qda_model01" ftype="zip" />
+            <param name="infile_model" value="qda_model01" ftype="h5mlm" />
             <param name="infile_data" value="test.tabular" ftype="tabular" />
-            <param name="header" value="True" />
             <param name="selected_task" value="load" />
             <output name="outfile_predict" file="qda_prediction_result01.tabular" />
         </test>