Page MenuHomePhabricator | MITK

Solvers exceptions due to missing hyper parameter configs should be more telling.
Closed, ResolvedPublic

Description

Currently the exception are not very telling when a config information for a hyperparameter needed by a solver is missing.
They are correct but very "technical" as they are the normal dictionary access exceptions for missing keys generated by python.

I think it is better to generate a more instructive exception that literaly tells something like: "Incorrect hyperparameter configuration. Chosen is missing property "y" for hyper parameter "z". Please add hyper parameter property to run solver.".

It happend to me e.g. when I was using the gridsearch solver.

I think a pragmatic solution would be to introduce a helper function with a signiture like:

def getHyperParameterProperty(config, parameterName, propertyName, isOptional=False, defaultValue = None):
''' Extracts the value of a certain property of a specified parameter.
  @param config: The hyppopy config dictionary containing the hyperparameters section.
  @param parameterName: Name of the parameter the property value is requested for.
  @param propertyName: Name of the property that is requested.
  @param isOptional: Indicates if the property is optional or mandatory.
  @return If the property exists for the parameter the value will be returned. If the value does not existis
  it depends on isOptional: True, defaultValue will be returned;  isOptional: False, an RuntimeError will be thrown.  
'''

Then we could use the helper in any solver and would always have instructive exceptions (if the exception text of the function is instructive ;).

Event Timeline

floca created this task.Apr 5 2019, 10:06 AM
floca triaged this task as Normal priority.
s635r closed this task as Resolved.Apr 30 2019, 2:14 PM