comparison generalized_linear.xml @ 13:cf635edf37d2 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5d71c93a3dd804b1469852240a86021ab9130364
author bgruening
date Mon, 09 Jul 2018 14:33:39 -0400
parents 513405ebad8b
children 10a8543142fc
comparison
equal deleted inserted replaced
12:513405ebad8b 13:cf635edf37d2
21 import pandas 21 import pandas
22 import pickle 22 import pickle
23 from scipy.io import mmread 23 from scipy.io import mmread
24 24
25 @COLUMNS_FUNCTION@ 25 @COLUMNS_FUNCTION@
26 @GET_X_y_FUNCTION@
26 27
27 input_json_path = sys.argv[1] 28 input_json_path = sys.argv[1]
28 params = json.load(open(input_json_path, "r")) 29 params = json.load(open(input_json_path, "r"))
29 30
30 #if $selected_tasks.selected_task == "train": 31 #if $selected_tasks.selected_task == "train":
31 32
33 X, y = get_X_y(params, "$selected_tasks.selected_algorithms.input_options.infile1" ,"$selected_tasks.selected_algorithms.input_options.infile2")
34
32 algorithm = params["selected_tasks"]["selected_algorithms"]["selected_algorithm"] 35 algorithm = params["selected_tasks"]["selected_algorithms"]["selected_algorithm"]
33 options = params["selected_tasks"]["selected_algorithms"]["options"] 36 options = params["selected_tasks"]["selected_algorithms"]["options"]
34
35 #if $selected_tasks.selected_algorithms.input_options.selected_input=="tabular":
36 header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header1"] else None
37 column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["selected_column_selector_option"]
38 if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]:
39 c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["col1"]
40 else:
41 c = None
42 X = read_columns(
43 "$selected_tasks.selected_algorithms.input_options.infile1",
44 c = c,
45 c_option = column_option,
46 sep='\t',
47 header=header,
48 parse_dates=True
49 )
50 #else:
51 X = mmread(open("$selected_tasks.selected_algorithms.input_options.infile1", 'r'))
52 #end if
53
54 header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header2"] else None
55 column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["selected_column_selector_option2"]
56 if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]:
57 c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["col2"]
58 else:
59 c = None
60 y = read_columns(
61 "$selected_tasks.selected_algorithms.input_options.infile2",
62 c = c,
63 c_option = column_option,
64 sep='\t',
65 header=header,
66 parse_dates=True
67 )
68 37
69 my_class = getattr(sklearn.linear_model, algorithm) 38 my_class = getattr(sklearn.linear_model, algorithm)
70 estimator = my_class(**options) 39 estimator = my_class(**options)
71 estimator.fit(X,y) 40 estimator.fit(X,y)
72 pickle.dump(estimator,open("$outfile_fit", 'w+'), pickle.HIGHEST_PROTOCOL) 41 pickle.dump(estimator,open("$outfile_fit", 'w+'), pickle.HIGHEST_PROTOCOL)