Mercurial > repos > goeckslab > ludwig_config_generator
comparison ludwig_autogenconfig.py @ 0:183adfc24076 draft default tip
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
author | goeckslab |
---|---|
date | Tue, 07 Jan 2025 22:46:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:183adfc24076 |
---|---|
1 import argparse | |
2 import logging | |
3 | |
4 from ludwig import automl | |
5 from ludwig.utils import defaults | |
6 | |
7 from pandas import read_csv | |
8 | |
9 logging.basicConfig(level=logging.DEBUG) | |
10 LOG = logging.getLogger(__name__) | |
11 | |
12 | |
13 def main(): | |
14 parser = argparse.ArgumentParser( | |
15 description='Render a Ludwig config') | |
16 parser.add_argument( | |
17 '--dataset', | |
18 type=str, | |
19 help='Path to the dataset file', | |
20 required=True) | |
21 parser.add_argument( | |
22 '--output_feature', | |
23 type=int, | |
24 help='Name for the output feature', | |
25 required=True) | |
26 parser.add_argument( | |
27 '--output', | |
28 type=str, | |
29 help='Path for the output file', | |
30 required=True) | |
31 parser.add_argument( | |
32 '--renderconfig', | |
33 action='store_true', | |
34 help='Render the config', | |
35 required=False, | |
36 default=False) | |
37 args = parser.parse_args() | |
38 | |
39 # get the output feature name | |
40 df = read_csv(args.dataset, nrows=2, sep=None, engine='python') | |
41 names = df.columns.tolist() | |
42 target = names[args.output_feature-1] | |
43 | |
44 args_init = ["--dataset", args.dataset, | |
45 "--target", target, | |
46 "--output", args.output] | |
47 automl.cli_init_config(args_init) | |
48 | |
49 if args.renderconfig: | |
50 args_render = ["--config", args.output, "--output", args.output] | |
51 defaults.cli_render_config(args_render) | |
52 | |
53 | |
54 if __name__ == "__main__": | |
55 main() |