Package: easyopt
easyopteasyoptis asuper simpleyetsuper powerfuloptuna-based Hyperparameters Optimization Framework that requiresno coding.FeaturesYAML ConfigurationDistributed Parallel OptimizationExperiments Monitoring and Crash RecoveringExperiments ReplicasReal Time PruningA wide variety of sampling strategiesTree-structured Parzen EstimatorCMA-ESGrid SearchRandom SearchA wide variety of pruning strategiesAsynchronous Successive Halving PruningHyperband PruningMedian PruningThreshold PruningA wide variety of DBMSsRedisSQLitePostgreSQLMySQLOracleAnd manymoreInstallationTo installeasyoptjust type:pip install easyoptExampleeasyoptexpects that hyperparameters are passed using the command line arguments.For example this problem has two hyperparametersxandyimportargparseparser=argparse.ArgumentParser()parser.add_argument("--x",type=float,required=True)parser.add_argument("--y",type=float,required=True)args=parser.parse_args()defobjective(x,y):returnx**2+y**2F=objective(args.x,args.y)To integrateeasyoptyou just have toimport easyoptAddeasyopt.objective(...)to report the experiment objective function valueThe above code becomes:importargparseimporteasyoptparser=argparse.ArgumentParser()parser.add_argument("--x",type=float,required=True)parser.add_argument("--y",type=float,required=True)args=parser.parse_args()defobjective(x,y):returnx**2+y**2F=objective(args.x,args.y)easyopt.objective(F)Next you have to create theeasyopt.ymlto define the problem search space, sampler, pruner, storage, etc.command:python problem.py {args}storage:sqlite:////tmp/easyopt-toy-problem.dbsampler:TPESamplerparameters:x:distribution:uniformlow:-10high:10y:distribution:uniformlow:-10high:10You can find the compete list of distributionshere(all thesuggest_*functions)Finally you have to create a studyeasyopt create test-studyAnd run as many agents as you wanteasyopt agent test-studyAfter a while the hyperparameter optimization will finishTrial 0 finished with value: 90.0401543850028 and parameters: {'x': 5.552902529323713, 'y': 7.694506344453366}. Best is trial 0 with value: 90.0401543850028.
Trial 1 finished with value: 53.38635524683359 and parameters: {'x': 0.26609756303111, 'y': 7.301749607716118}. Best is trial 1 with value: 53.38635524683359.
Trial 2 finished with value: 64.41207387363161 and parameters: {'x': 7.706366704967074, 'y': 2.2414250115064167}. Best is trial 1 with value: 53.38635524683359.
...
...
Trial 53 finished with value: 0.5326245807950265 and parameters: {'x': -0.26584110075742917, 'y': 0.6796713102251005}. Best is trial 35 with value: 0.11134607529340049.
Trial 54 finished with value: 8.570230212116037 and parameters: {'x': 2.8425893061307295, 'y': 0.6999401751487438}. Best is trial 35 with value: 0.11134607529340049.
Trial 55 finished with value: 96.69479467451664 and parameters: {'x': -0.3606041968175481, 'y': -9.826736960342137}. Best is trial 35 with value: 0.11134607529340049.YAML StructureTheYAMLconfiguration file is structured as followscommand:<command>storage:<storage>sampler:<sampler>pruner:<pruner>direction:<direction>replicas:<replicas>parameters:parameter-1:distribution:<distribution><arg1>:<value1><arg2>:<value2>......command: the command to execute to run the experiment.{args}will be expanded to--parameter-1=value-1 --parameter-2=value-2{name}will be expanded to the study namestorage: the storage to use for the study. A full list of storages is availableheresampler: the sampler to use. The full list of samplers is availableherepruner: the pruner to use. The full list of pruners is availableheredirection: can beminimizeormaximize(default:minimize)replicas: the number of replicas to run for the same experiment (the experiment result is the average). (default:1)parameters: the parameters to optimizefor each parameter have to specifydistributionthe distribution to use. The full list of distributions is availablehere(all thesuggest_*functions)arg:valueArguments of the distribution. The arguments documentation is availablehereCLI Interfaceeasyoptoffer two CLI commands:createto create a study using theeasyopt.ymlfile or the one specified with--configagent <study_name>to run the agent for<study_name>LIB InterfaceWhen importingeasyoptyou can use three functions:easyopt.objective(value)to report thefinalobjective function value of the experimenteasyopt.report(value)to report thecurrentobjective function value of the experiment (used by the pruner)easyopt.should_prune()it returnsTrueif the pruner thinks that the run should be prunedExamplesYou can find some exampleshereContributions and licenseThe code is released as Free Software under theGNU/GPLv3license. Copying, adapting and republishing it is not only allowed but also encouraged.For any further question feel free to reach me atfederico.galatolo@ing.unipi.itor on Telegram@galatolo