comparison main_macros.xml @ 14:4dcf3f6c7026 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 4ed8c4f6ef9ece81797a398b17a99bbaf49a6978
author bgruening
date Wed, 30 May 2018 08:19:52 -0400
parents ec9bf0551763
children 44a89bae67ae
comparison
equal deleted inserted replaced
13:ec9bf0551763 14:4dcf3f6c7026
12 if return_df: 12 if return_df:
13 return y, data 13 return y, data
14 else: 14 else:
15 return y 15 return y
16 return y 16 return y
17 </token>
18
19 ## generate an instance for one of sklearn.feature_selection classes
20 ## must call "@COLUMNS_FUNCTION@"
21 <token name="@FEATURE_SELECTOR_FUNCTION@">
22 def feature_selector(inputs):
23 selector = inputs["selected_algorithm"]
24 selector = getattr(sklearn.feature_selection, selector)
25 options = inputs["options"]
26
27 if inputs['selected_algorithm'] == 'SelectFromModel':
28 if not options['threshold'] or options['threshold'] == 'None':
29 options['threshold'] = None
30 if 'extra_estimator' in inputs and inputs['extra_estimator']['has_estimator'] == 'no_load':
31 fitted_estimator = pickle.load(open("inputs['extra_estimator']['fitted_estimator']", 'r'))
32 new_selector = selector(fitted_estimator, prefit=True, **options)
33 else:
34 estimator=inputs["estimator"]
35 if inputs["extra_estimator"]["has_estimator"]=='no':
36 estimator=inputs["extra_estimator"]["new_estimator"]
37 estimator=eval(estimator.replace('__dq__', '"').replace("__sq__","'"))
38 new_selector = selector(estimator, **options)
39
40 elif inputs['selected_algorithm'] in ['RFE', 'RFECV']:
41 if 'scoring' in options and (not options['scoring'] or options['scoring'] == 'None'):
42 options['scoring'] = None
43 estimator=inputs["estimator"]
44 if inputs["extra_estimator"]["has_estimator"]=='no':
45 estimator=inputs["extra_estimator"]["new_estimator"]
46 estimator=eval(estimator.replace('__dq__', '"').replace("__sq__","'"))
47 new_selector = selector(estimator, **options)
48
49 elif inputs['selected_algorithm'] == "VarianceThreshold":
50 new_selector = selector(**options)
51
52 else:
53 score_func = inputs["score_func"]
54 score_func = getattr(sklearn.feature_selection, score_func)
55 new_selector = selector(score_func, **options)
56
57 return new_selector
17 </token> 58 </token>
18 59
19 <xml name="python_requirements"> 60 <xml name="python_requirements">
20 <requirements> 61 <requirements>
21 <requirement type="package" version="2.7">python</requirement> 62 <requirement type="package" version="2.7">python</requirement>
792 label="Use a copy of data for precomputing row normalization" help=" "/> 833 label="Use a copy of data for precomputing row normalization" help=" "/>
793 </section> 834 </section>
794 </when> 835 </when>
795 <yield/> 836 <yield/>
796 </xml> 837 </xml>
838 <xml name="estimator_input_no_fit">
839 <expand macro="feature_selection_estimator" />
840 <conditional name="extra_estimator">
841 <expand macro="feature_selection_extra_estimator" />
842 <expand macro="feature_selection_estimator_choices" />
843 </conditional>
844 </xml>
797 <xml name="feature_selection_all"> 845 <xml name="feature_selection_all">
798 <conditional name="feature_selection_algorithms"> 846 <conditional name="feature_selection_algorithms">
799 <param name="selected_algorithm" type="select" label="Select a feature selection algorithm"> 847 <param name="selected_algorithm" type="select" label="Select a feature selection algorithm">
800 <option value="SelectFromModel" selected="true">SelectFromModel - Meta-transformer for selecting features based on importance weights</option> 848 <option value="SelectFromModel" selected="true">SelectFromModel - Meta-transformer for selecting features based on importance weights</option>
801 <option value="GenericUnivariateSelect" selected="true">GenericUnivariateSelect - Univariate feature selector with configurable strategy</option> 849 <option value="GenericUnivariateSelect" selected="true">GenericUnivariateSelect - Univariate feature selector with configurable strategy</option>
973 1021
974 <xml name="scoring"> 1022 <xml name="scoring">
975 <param argument="scoring" type="text" value="" optional="true" label="scoring" help="A metric used to evaluate the estimator"/> 1023 <param argument="scoring" type="text" value="" optional="true" label="scoring" help="A metric used to evaluate the estimator"/>
976 </xml> 1024 </xml>
977 1025
978 <xml name="pre_dispatch"> 1026 <xml name="pre_dispatch" token_type="text" token_default_value="all" token_help="Number of predispatched jobs for parallel execution">
979 <param argument="pre_dispatch" type="text" value="all" optional="true" label="pre_dispatch" help="Number of predispatched jobs for parallel execution"/> 1027 <param argument="pre_dispatch" type="@TYPE@" value="@DEFAULT_VALUE@" optional="true" label="pre_dispatch" help="@HELP@"/>
980 </xml> 1028 </xml>
981 1029
982 <!-- Outputs --> 1030 <!-- Outputs -->
983 1031
984 <xml name="output"> 1032 <xml name="output">