Mercurial > repos > bgruening > sklearn_ensemble
comparison label_encoder.py @ 41:6546d7c9f08b draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 9981e25b00de29ed881b2229a173a8c812ded9bb
author | bgruening |
---|---|
date | Wed, 09 Aug 2023 12:52:25 +0000 |
parents | 4ecc0ce9d0a2 |
children |
comparison
equal
deleted
inserted
replaced
40:a07ab242b0b5 | 41:6546d7c9f08b |
---|---|
19 | 19 |
20 outfile : str | 20 outfile : str |
21 File path to output vector | 21 File path to output vector |
22 | 22 |
23 """ | 23 """ |
24 warnings.simplefilter('ignore') | 24 warnings.simplefilter("ignore") |
25 | 25 |
26 with open(inputs, 'r') as param_handler: | 26 with open(inputs, "r") as param_handler: |
27 params = json.load(param_handler) | 27 params = json.load(param_handler) |
28 | 28 |
29 input_header = params['header0'] | 29 input_header = params["header0"] |
30 header = 'infer' if input_header else None | 30 header = "infer" if input_header else None |
31 | 31 |
32 input_vector = pd.read_csv(infile, sep='\t', header=header) | 32 input_vector = pd.read_csv(infile, sep="\t", header=header) |
33 | 33 |
34 le = LabelEncoder() | 34 le = LabelEncoder() |
35 | 35 |
36 output_vector = le.fit_transform(input_vector) | 36 output_vector = le.fit_transform(input_vector) |
37 | 37 |
38 np.savetxt(outfile, output_vector, fmt="%d", delimiter='\t') | 38 np.savetxt(outfile, output_vector, fmt="%d", delimiter="\t") |
39 | 39 |
40 | 40 |
41 if __name__ == '__main__': | 41 if __name__ == "__main__": |
42 aparser = argparse.ArgumentParser() | 42 aparser = argparse.ArgumentParser() |
43 aparser.add_argument("-i", "--inputs", dest="inputs", required=True) | 43 aparser.add_argument("-i", "--inputs", dest="inputs", required=True) |
44 aparser.add_argument("-y", "--infile", dest="infile") | 44 aparser.add_argument("-y", "--infile", dest="infile") |
45 aparser.add_argument("-o", "--outfile", dest="outfile") | 45 aparser.add_argument("-o", "--outfile", dest="outfile") |
46 args = aparser.parse_args() | 46 args = aparser.parse_args() |