Skip to content

Conversation

@thijssnelleman
Copy link
Collaborator

  • Removed Hyperparameter from all clauses regarding forbidden / conditions, leaving all else intact
  • Recalculated the node depth for only the affected nodes in the tree

@thijssnelleman
Copy link
Collaborator Author

@mfeurer @eddiebergman

I updated the structure to now rebuild the DAG: "Now the ConfigurationSpace.remove does all the work, at the end it reset dag by self._dag = Dag() and adds all parameters/conditions/forbiddens as done in ConfigurationSpace.init"

I think after review, with a few minor changes, this can be merged

@thijssnelleman
Copy link
Collaborator Author

@mfeurer Reminder for this PR

) -> None:
"""Remove a hyperparameter from the configuration space.

If the hyperparameter has children, the children are also removed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that this is underspecified. What happens if a child has multiple parents? In cases they child node depends on them via a and condition, the child needs to be removed, but if it depends on them via an or condition, it could stay. Maybe the behavior should be based on a flag?

remove_hps_names = [hp.name for hp in remove_hps]

# Filter HPs from the DAG
hps: list[Hyperparameter] = [node.hp for node in self._dag.nodes.values() if node.hp.name not in remove_hps_names]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would the code remove children?

new_components.append(new_component)
if len(new_components) >= 2: # Can create a conjunction
return type(target)(*new_components)
if len(new_components) == 1: # Only one component remains
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(new_components) == 1: # Only one component remains
elif len(new_components) == 1: # Only one component remains

target.left.name in remove_hps_names or target.right.name in remove_hps_names
):
return None
if isinstance(target, ForbiddenClause) and target.hyperparameter.name in remove_hps_names:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if isinstance(target, ForbiddenClause) and target.hyperparameter.name in remove_hps_names:
elif isinstance(target, ForbiddenClause) and target.hyperparameter.name in remove_hps_names:

return None
if isinstance(target, ForbiddenClause) and target.hyperparameter.name in remove_hps_names:
return None
if isinstance(target, Condition) and (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if isinstance(target, Condition) and (
elif isinstance(target, Condition) and (

target.parent.name in remove_hps_names or target.child.name in remove_hps_names
):
return None
if isinstance(target, (Conjunction, ForbiddenConjunction)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if isinstance(target, (Conjunction, ForbiddenConjunction)):
elif isinstance(target, (Conjunction, ForbiddenConjunction)):


ignore = [
"T201", # TODO: Remove
"COM812", # Causes issues with ruff formatter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this line disable exactly?

cs.add(cond)
cs.remove(hp)
assert len(cs) == 2
assert cs.conditional_hyperparameters == []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think checking that the length is 0 would be better?

assert len(cs) == 1
assert cs.forbidden_clauses == []

# And now for more complicated conditions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please describe this more complicated relation, i.e., briefly explain the dependency structure and what you intend to test?

== "((constant1 | input1 == 1 && constant1 | input2 != 1) && constant1 | input4 == 1 && constant1 | input5 == 1)"
)

# Now more complicated forbiddens
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please split this test in smaller chunks that test similar things?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants