comparison discriminant.xml @ 15:fb232caca397 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit f54ff2ba2f8e7542d68966ce5a6b17d7f624ac48
author bgruening
date Fri, 13 Jul 2018 03:56:21 -0400
parents f46da2feb233
children 98b632c407ae
comparison
equal deleted inserted replaced
14:6ffb5d3bfc08 15:fb232caca397
24 24
25 @COLUMNS_FUNCTION@ 25 @COLUMNS_FUNCTION@
26 @GET_X_y_FUNCTION@ 26 @GET_X_y_FUNCTION@
27 27
28 input_json_path = sys.argv[1] 28 input_json_path = sys.argv[1]
29 params = json.load(open(input_json_path, "r")) 29 with open(input_json_path, "r") as param_handler:
30 30 params = json.load(param_handler)
31 31
32 #if $selected_tasks.selected_task == "load": 32 #if $selected_tasks.selected_task == "load":
33 33
34 classifier_object = pickle.load(open("$infile_model", 'r')) 34 with open("$infile_model", 'rb') as model_handler:
35 classifier_object = pickle.load(model_handler)
35 36
36 header = 'infer' if params["selected_tasks"]["header"] else None 37 header = 'infer' if params["selected_tasks"]["header"] else None
37 data = pandas.read_csv("$selected_tasks.infile_data", sep='\t', header=header, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False) 38 data = pandas.read_csv("$selected_tasks.infile_data", sep='\t', header=header, index_col=None, parse_dates=True, encoding=None, tupleize_cols=False)
38 prediction = classifier_object.predict(data) 39 prediction = classifier_object.predict(data)
39 prediction_df = pandas.DataFrame(prediction) 40 prediction_df = pandas.DataFrame(prediction)
48 selected_algorithm = params["selected_tasks"]["selected_algorithms"]["selected_algorithm"] 49 selected_algorithm = params["selected_tasks"]["selected_algorithms"]["selected_algorithm"]
49 50
50 my_class = getattr(sklearn.discriminant_analysis, selected_algorithm) 51 my_class = getattr(sklearn.discriminant_analysis, selected_algorithm)
51 classifier_object = my_class(**options) 52 classifier_object = my_class(**options)
52 classifier_object.fit(X, y) 53 classifier_object.fit(X, y)
53 pickle.dump(classifier_object,open("$outfile_fit", 'w+'), pickle.HIGHEST_PROTOCOL) 54 with open("$outfile_fit", 'wb') as out_handler:
55 pickle.dump(classifier_object, out_handler, pickle.HIGHEST_PROTOCOL)
54 56
55 #end if 57 #end if
56 ]]> 58 ]]>
57 </configfile> 59 </configfile>
58 </configfiles> 60 </configfiles>