# HG changeset patch
# User bgruening
# Date 1533634867 14400
# Node ID b622535c2a8da08cde1331b469cf955d7e09eb02
# Parent 10f6c832d6583ecbdd3b22c2e035a67e9f136af2
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit b1e5fa3170484d2cc3396f2abe99bb8cfcfa9c65
diff -r 10f6c832d658 -r b622535c2a8d main_macros.xml
--- a/main_macros.xml Sat Aug 04 17:30:33 2018 -0400
+++ b/main_macros.xml Tue Aug 07 05:41:07 2018 -0400
@@ -100,53 +100,55 @@
return X, y
+
+def safe_eval(literal):
+
+ FROM_SCIPY_STATS = [ 'bernoulli', 'binom', 'boltzmann', 'dlaplace', 'geom', 'hypergeom',
+ 'logser', 'nbinom', 'planck', 'poisson', 'randint', 'skellam', 'zipf' ]
+
+ FROM_NUMPY_RANDOM = [ 'beta', 'binomial', 'bytes', 'chisquare', 'choice', 'dirichlet', 'division',
+ 'exponential', 'f', 'gamma', 'geometric', 'gumbel', 'hypergeometric',
+ 'laplace', 'logistic', 'lognormal', 'logseries', 'mtrand', 'multinomial',
+ 'multivariate_normal', 'negative_binomial', 'noncentral_chisquare', 'noncentral_f',
+ 'normal', 'pareto', 'permutation', 'poisson', 'power', 'rand', 'randint',
+ 'randn', 'random', 'random_integers', 'random_sample', 'ranf', 'rayleigh',
+ 'sample', 'seed', 'set_state', 'shuffle', 'standard_cauchy', 'standard_exponential',
+ 'standard_gamma', 'standard_normal', 'standard_t', 'triangular', 'uniform',
+ 'vonmises', 'wald', 'weibull', 'zipf' ]
+
+ # File opening and other unneeded functions could be dropped
+ UNWANTED = ['open', 'type', 'dir', 'id', 'str', 'repr']
+
+ # Allowed symbol table. Add more if needed.
+ new_syms = {
+ 'np_arange': getattr(np, 'arange'),
+ 'ensemble_ExtraTreesClassifier': getattr(ensemble, 'ExtraTreesClassifier')
+ }
+
+ syms = make_symbol_table(use_numpy=False, **new_syms)
+
+ for method in FROM_SCIPY_STATS:
+ syms['scipy_stats_' + method] = getattr(scipy.stats, method)
+
+ for func in FROM_NUMPY_RANDOM:
+ syms['np_random_' + func] = getattr(np.random, func)
+
+ for key in UNWANTED:
+ syms.pop(key, None)
+
+ aeval = Interpreter(symtable=syms, use_numpy=False, minimal=False,
+ no_if=True, no_for=True, no_while=True, no_try=True,
+ no_functiondef=True, no_ifexp=True, no_listcomp=False,
+ no_augassign=False, no_assert=True, no_delete=True,
+ no_raise=True, no_print=True)
+
+ return aeval(literal)
+
+
def get_search_params(params_builder):
search_params = {}
- def safe_eval(literal):
-
- FROM_SCIPY_STATS = [ 'bernoulli', 'binom', 'boltzmann', 'dlaplace', 'geom', 'hypergeom',
- 'logser', 'nbinom', 'planck', 'poisson', 'randint', 'skellam', 'zipf' ]
-
- FROM_NUMPY_RANDOM = [ 'beta', 'binomial', 'bytes', 'chisquare', 'choice', 'dirichlet', 'division',
- 'exponential', 'f', 'gamma', 'geometric', 'gumbel', 'hypergeometric',
- 'laplace', 'logistic', 'lognormal', 'logseries', 'mtrand', 'multinomial',
- 'multivariate_normal', 'negative_binomial', 'noncentral_chisquare', 'noncentral_f',
- 'normal', 'pareto', 'permutation', 'poisson', 'power', 'rand', 'randint',
- 'randn', 'random', 'random_integers', 'random_sample', 'ranf', 'rayleigh',
- 'sample', 'seed', 'set_state', 'shuffle', 'standard_cauchy', 'standard_exponential',
- 'standard_gamma', 'standard_normal', 'standard_t', 'triangular', 'uniform',
- 'vonmises', 'wald', 'weibull', 'zipf' ]
-
- # File opening and other unneeded functions could be dropped
- UNWANTED = ['open', 'type', 'dir', 'id', 'str', 'repr']
-
- # Allowed symbol table. Add more if needed.
- new_syms = {
- 'np_arange': getattr(np, 'arange'),
- 'ensemble_ExtraTreesClassifier': getattr(ensemble, 'ExtraTreesClassifier')
- }
-
- syms = make_symbol_table(use_numpy=False, **new_syms)
-
- for method in FROM_SCIPY_STATS:
- syms['scipy_stats_' + method] = getattr(scipy.stats, method)
-
- for func in FROM_NUMPY_RANDOM:
- syms['np_random_' + func] = getattr(np.random, func)
-
- for key in UNWANTED:
- syms.pop(key, None)
-
- aeval = Interpreter(symtable=syms, use_numpy=False, minimal=False,
- no_if=True, no_for=True, no_while=True, no_try=True,
- no_functiondef=True, no_ifexp=True, no_listcomp=False,
- no_augassign=False, no_assert=True, no_delete=True,
- no_raise=True, no_print=True)
-
- return aeval(literal)
-
for p in params_builder['param_set']:
search_p = p['search_param_selector']['search_p']
if search_p.strip() == '':
@@ -189,6 +191,20 @@
return estimator
+
+def get_cv(literal):
+ if literal == "":
+ return None
+ if re.match(r'^\d+$', literal):
+ return int(literal)
+ m = re.match(r'^(?P<method>\w+)\((?P<args>.*)\)$', literal)
+ if m:
+ my_class = getattr( model_selection, m.group('method') )
+ args = safe_eval( 'dict('+ m.group('args') + ')' )
+ return my_class( **args )
+ sys.exit("Unsupported CV input: %s" %literal)
+
+
python
@@ -1143,7 +1159,7 @@
-
+