{"record":{"id":"8855e0dc94bda844","repo":"microsoft/qlib","slug":"optim-type-should-be-min-max-or-correlation","errorCode":null,"errorMessage":"optim_type should be min, max or correlation","messagePattern":"optim_type should be min, max or correlation","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/contrib/tuner/config.py","lineNumber":90,"sourceCode":"            )\n\n        self.report_factor = config.get(\"report_factor\", \"information_ratio\")\n        if self.report_factor not in [\n            \"annualized_return\",\n            \"information_ratio\",\n            \"max_drawdown\",\n            \"mean\",\n            \"std\",\n            \"model_score\",\n            \"model_pearsonr\",\n        ]:\n            raise ValueError(\n                \"report_factor should be one of annualized_return, information_ratio, max_drawdown, mean, std, model_pearsonr and model_score\"\n            )\n\n        self.optim_type = config.get(\"optim_type\", \"max\")\n        if self.optim_type not in [\"min\", \"max\", \"correlation\"]:\n            raise ValueError(\"optim_type should be min, max or correlation\")\n","sourceCodeStart":72,"sourceCodeEnd":91,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/tuner/config.py#L72-L91","documentation":"OptimizationConfig (qlib/contrib/tuner/config.py) validates optim_type, which tells the tuner how to compare trials: 'min' (minimize the factor), 'max' (maximize it), or 'correlation' (rank trials by correlation). Any other value raises ValueError at config load time.","triggerScenarios":"A tuner YAML with optimization_criteria: optim_type: minimize (or 'Min', 'avg', None-as-string, etc.) raises ValueError when TunerConfigManager parses the file.","commonSituations":"Writing 'minimize'/'maximize' out of habit from other hyperparameter frameworks (optuna, ray tune); case sensitivity issues; YAML unquoted values being parsed into unexpected types.","solutions":["Set optim_type to exactly 'min', 'max', or 'correlation'","Quote the value in YAML to avoid parser surprises","Remember 'correlation' is for matching trial reports against a reference, not for min/max optimization"],"exampleFix":"# before (tuner_config.yaml)\noptimization_criteria:\n  optim_type: maximize\n\n# after\noptimization_criteria:\n  optim_type: max","handlingStrategy":"validation","validationCode":"assert cfg['optimization_criteria']['optim_type'] in ('min', 'max', 'correlation')","typeGuard":"def is_valid_optim_type(t: str) -> bool:\n    return t in {'min', 'max', 'correlation'}","tryCatchPattern":null,"preventionTips":["Use the short forms 'min'/'max', not 'minimize'/'maximize'","Quote YAML scalars to avoid type coercion surprises"],"tags":["qlib","tuner","configuration","validation"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}