run_openML_surrogate.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import os, argparse
  2. open_ml_problems_folder = 'OpenML_datasets'
  3. def main():
  4. parser = argparse.ArgumentParser(description="Find best features for each OpenML problems")
  5. parser.add_argument('--ils', type=int, help='number of total iteration for ils algorithm', required=True)
  6. parser.add_argument('--ls', type=int, help='number of iteration for Local Search algorithm', required=True)
  7. args = parser.parse_args()
  8. p_ils = args.ils
  9. p_ls = args.ls
  10. open_ml_problems = sorted(os.listdir(open_ml_problems_folder))
  11. for ml_problem in open_ml_problems:
  12. ml_problem_name = ml_problem.replace('.csv', '')
  13. ml_problem_path = os.path.join(open_ml_problems_folder, ml_problem)
  14. ml_surrogate_command = f"python find_best_attributes_surrogate_openML.py " \
  15. f"--data {ml_problem_path} " \
  16. f"--ils {p_ils} " \
  17. f"--ls {p_ls} " \
  18. f"--output {ml_problem_name}"
  19. print(f'Run surrogate features selection for {ml_problem_name} with [ils: {p_ils}, ls: {p_ls}]')
  20. print(ml_surrogate_command)
  21. os.system(ml_surrogate_command)
  22. if __name__ == "__main__":
  23. main()