# HG changeset patch
# User bgruening
# Date 1531468519 14400
# Node ID f02eeabab5d1a425ab52cdd9e8b2ef15db3646f0
# Parent 84724d805bfa2d80a61837ebc588b25c8d765b80
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit f54ff2ba2f8e7542d68966ce5a6b17d7f624ac48
diff -r 84724d805bfa -r f02eeabab5d1 ensemble.xml
--- a/ensemble.xml Tue Jul 10 03:11:34 2018 -0400
+++ b/ensemble.xml Fri Jul 13 03:55:19 2018 -0400
@@ -27,8 +27,9 @@
# Get inputs, outputs.
input_json_path = sys.argv[1]
-params = json.load(open(input_json_path, "r"))
-print params
+with open(input_json_path, "r") as param_handler:
+ params = json.load(param_handler)
+print(params)
# Put all cheetah up here to avoid confusion.
#if $selected_tasks.selected_task == "train":
@@ -63,14 +64,16 @@
options["min_samples_split"] = int(options["min_samples_split"])
X, y = get_X_y(params, infile1, infile2)
-
+
my_class = getattr(sklearn.ensemble, algorithm)
estimator = my_class(**options)
estimator.fit(X,y)
- pickle.dump(estimator,open(outfile_fit, 'w+'), pickle.HIGHEST_PROTOCOL)
+ with open(outfile_fit, 'wb') as out_handler:
+ pickle.dump(estimator, out_handler, pickle.HIGHEST_PROTOCOL)
else:
- classifier_object = pickle.load(open(infile_model, 'r'))
+ with open(infile_model, 'rb') as model_handler:
+ classifier_object = pickle.load(model_handler)
header = 'infer' if params["selected_tasks"]["header"] else None
data = pandas.read_csv(infile_data, sep='\t', header=header, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False)
prediction = classifier_object.predict(data)
diff -r 84724d805bfa -r f02eeabab5d1 main_macros.xml
--- a/main_macros.xml Tue Jul 10 03:11:34 2018 -0400
+++ b/main_macros.xml Fri Jul 13 03:55:19 2018 -0400
@@ -35,7 +35,8 @@
if not options['threshold'] or options['threshold'] == 'None':
options['threshold'] = None
if 'extra_estimator' in inputs and inputs['extra_estimator']['has_estimator'] == 'no_load':
- fitted_estimator = pickle.load(open("inputs['extra_estimator']['fitted_estimator']", 'r'))
+ with open("inputs['extra_estimator']['fitted_estimator']", 'rb') as model_handler:
+ fitted_estimator = pickle.load(model_handler)
new_selector = selector(fitted_estimator, prefit=True, **options)
else:
estimator=inputs["estimator"]
@@ -83,7 +84,7 @@
parse_dates=True
)
else:
- X = mmread(open(file1, 'r'))
+ X = mmread(file1)
header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header2"] else None
column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["selected_column_selector_option2"]
@@ -432,19 +433,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -472,13 +460,13 @@
-
+
-
+
@@ -553,11 +541,6 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -892,6 +914,7 @@
+
@@ -1014,6 +1037,7 @@
+
@@ -1023,6 +1047,7 @@
+
@@ -1032,6 +1057,7 @@
+
@@ -1039,6 +1065,7 @@
+
@@ -1047,6 +1074,7 @@
+
diff -r 84724d805bfa -r f02eeabab5d1 test-data/mv_result07.tabular
--- a/test-data/mv_result07.tabular Tue Jul 10 03:11:34 2018 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-0.7824428015300172