Mercurial > repos > bgruening > sklearn_data_preprocess
comparison pre_process.xml @ 21:f156acc7239b draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 2a058459e6daf0486871f93845f00fdb4a4eaca1
author | bgruening |
---|---|
date | Sat, 29 Sep 2018 07:31:15 -0400 |
parents | f196d4715cfb |
children | d6b8103c909c |
comparison
equal
deleted
inserted
replaced
20:2bda387c73e4 | 21:f156acc7239b |
---|---|
21 import pickle | 21 import pickle |
22 from scipy.io import mmread | 22 from scipy.io import mmread |
23 from scipy.io import mmwrite | 23 from scipy.io import mmwrite |
24 from sklearn import preprocessing | 24 from sklearn import preprocessing |
25 | 25 |
26 execfile("$__tool_directory__/utils.py") | 26 exec(open("$__tool_directory__/utils.py").read(), globals()) |
27 | 27 |
28 input_json_path = sys.argv[1] | 28 input_json_path = sys.argv[1] |
29 with open(input_json_path, "r") as param_handler: | 29 with open(input_json_path, "r") as param_handler: |
30 params = json.load(param_handler) | 30 params = json.load(param_handler) |
31 | 31 |
58 estimator = my_class(**options) | 58 estimator = my_class(**options) |
59 estimator.fit(X) | 59 estimator.fit(X) |
60 result = estimator.transform(X) | 60 result = estimator.transform(X) |
61 | 61 |
62 #if $input_type.selected_input_type == "sparse": | 62 #if $input_type.selected_input_type == "sparse": |
63 with open("$outfile_transform", "w+") as transform_handler: | 63 with open("$outfile_transform", "wb") as transform_handler: |
64 mmwrite(transform_handler, result) | 64 mmwrite(transform_handler, result) |
65 #else: | 65 #else: |
66 res = pandas.DataFrame(result) | 66 res = pandas.DataFrame(result) |
67 res.to_csv(path_or_buf = "$outfile_transform", sep="\t", index=False, header=None) | 67 res.to_csv(path_or_buf = "$outfile_transform", sep="\t", index=False, header=None) |
68 #end if | 68 #end if |