comparison ensemble.xml @ 20:038cecaa9e7c draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 8cf3d813ec755166ee0bd517b4ecbbd4f84d4df1
author bgruening
date Thu, 23 Aug 2018 16:16:12 -0400
parents 4570575d060c
children 9ce3e347506c
comparison
equal deleted inserted replaced
19:4570575d060c 20:038cecaa9e7c
18 import os 18 import os
19 import json 19 import json
20 import numpy as np 20 import numpy as np
21 import sklearn.ensemble 21 import sklearn.ensemble
22 import pandas 22 import pandas
23 import pickle
24 from scipy.io import mmread 23 from scipy.io import mmread
25 24
26 execfile("$__tool_directory__/utils.py") 25 execfile("$__tool_directory__/sk_whitelist.py")
26 execfile("$__tool_directory__/utils.py", globals())
27 27
28 # Get inputs, outputs. 28 # Get inputs, outputs.
29 input_json_path = sys.argv[1] 29 input_json_path = sys.argv[1]
30 with open(input_json_path, "r") as param_handler: 30 with open(input_json_path, "r") as param_handler:
31 params = json.load(param_handler) 31 params = json.load(param_handler)
73 with open(outfile_fit, 'wb') as out_handler: 73 with open(outfile_fit, 'wb') as out_handler:
74 pickle.dump(estimator, out_handler, pickle.HIGHEST_PROTOCOL) 74 pickle.dump(estimator, out_handler, pickle.HIGHEST_PROTOCOL)
75 75
76 else: 76 else:
77 with open(infile_model, 'rb') as model_handler: 77 with open(infile_model, 'rb') as model_handler:
78 classifier_object = pickle.load(model_handler) 78 classifier_object = SafePickler.load(model_handler)
79 header = 'infer' if params["selected_tasks"]["header"] else None 79 header = 'infer' if params["selected_tasks"]["header"] else None
80 data = pandas.read_csv(infile_data, sep='\t', header=header, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False) 80 data = pandas.read_csv(infile_data, sep='\t', header=header, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False)
81 prediction = classifier_object.predict(data) 81 prediction = classifier_object.predict(data)
82 prediction_df = pandas.DataFrame(prediction, columns=["predicted"]) 82 prediction_df = pandas.DataFrame(prediction, columns=["predicted"])
83 res = pandas.concat([data, prediction_df], axis=1) 83 res = pandas.concat([data, prediction_df], axis=1)