Skip to content

Commit

Permalink
Solve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Krebs committed Oct 27, 2023
2 parents 430d0ac + 72fa354 commit 08aa5fd
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Bug-Fixes
- Fix seaborn style name (#82).
- Remove potential sources of nondeterminism in evaluators by not setting seeds randomly (#75).
- Exchange SMAC log examples to fix issue with PDP (#54).

# Version 1.1.2
Expand Down
2 changes: 1 addition & 1 deletion deepcave/evaluators/epm/fanova_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
instance_features: Optional[np.ndarray] = None,
pca_components: Optional[int] = 2,
cutoffs: Tuple[float, float] = (-np.inf, np.inf),
seed: Optional[int] = None,
seed: int = 0,
):
super().__init__(
configspace=configspace,
Expand Down
4 changes: 1 addition & 3 deletions deepcave/evaluators/epm/random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
instance_features: Optional[np.ndarray] = None,
pca_components: Optional[int] = 2,
log_y: bool = False,
seed: Optional[int] = None,
seed: int = 0,
):
self.cs = configspace
self.log_y = log_y
Expand Down Expand Up @@ -295,8 +295,6 @@ def _train(self, X: np.ndarray, Y: np.ndarray) -> None:
# Now we can start to prepare the data for the pyrfr
data = self._get_data_container(X, Y.flatten())
seed = self.seed
if seed is None:
seed = int(random() * 9999)

rng = regression.default_random_engine(seed)

Expand Down
6 changes: 3 additions & 3 deletions deepcave/evaluators/fanova.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def calculate(
objectives: Optional[Union[Objective, List[Objective]]] = None,
budget: Optional[Union[int, float]] = None,
n_trees: int = 16,
seed: Optional[int] = None,
seed: int = 0,
) -> None:
"""
Get the data wrt budget and trains the forest on the encoded data.
Expand All @@ -47,8 +47,8 @@ def calculate(
Considered budget. By default None. If None, the highest budget is chosen.
n_trees : int, optional
How many trees should be used. By default 16.
seed : Optional[int], optional
Random seed. By default None.
seed : int
Random seed. By default 0.
"""
if objectives is None:
objectives = self.run.get_objectives()
Expand Down
5 changes: 1 addition & 4 deletions deepcave/evaluators/lpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def calculate(
budget: Optional[Union[int, float]] = None,
continous_neighbors: int = 500,
n_trees: int = 10,
seed: Optional[int] = None,
seed: int = 0,
) -> None:
"""
Prepares the data and trains a RandomForest model.
Expand All @@ -56,9 +56,6 @@ def calculate(
self.default = self.cs.get_default_configuration()
self.incumbent_array = self.incumbent.get_array()

# Set the seed
if seed is None:
seed = int(random() * 9999)
self.seed = seed
self.rs = np.random.RandomState(seed)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jsonlines>=3.0.0
pandas>=1.3.4
numpy>=1.22.2
matplotlib>=3.5.1
seaborn>=0.12.2
seaborn>=0.13.0
pyyaml

# AutoML packages
Expand Down
8 changes: 4 additions & 4 deletions tests/test_evaluators/test_fanova.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ def test(self):
objective = self.run.get_objective(0)

# Calculate
self.evaluator.calculate(objective, budget)
self.evaluator.calculate(objective, budget, seed=0)
importances = self.evaluator.get_importances(self.hp_names)

self.evaluator.calculate(objective, budget)
self.evaluator.calculate(objective, budget, seed=42)
importances2 = self.evaluator.get_importances(self.hp_names)

# No seed: Different results
# Different seed: Different results
assert importances["batch_size"][1] != importances2["batch_size"][1]

def test_seed(self):
Expand All @@ -42,7 +42,7 @@ def test_seed(self):
importances2 = self.evaluator.get_importances(self.hp_names)

# No seed: Different results
assert importances["batch_size"][1] == importances2["batch_size"][1]
assert importances["n_neurons"][1] == importances2["n_neurons"][1]


if __name__ == "__main__":
Expand Down

0 comments on commit 08aa5fd

Please sign in to comment.