Skip to content

Commit

Permalink
Reduced the space #24
Browse files Browse the repository at this point in the history
  • Loading branch information
johnantonn committed Mar 19, 2022
1 parent 08ecc40 commit 3353c3b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 44 deletions.
18 changes: 9 additions & 9 deletions src/pyod_models/cblof.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ConfigSpace.configuration_space import ConfigurationSpace
from ConfigSpace.hyperparameters import UniformIntegerHyperparameter, \
UniformFloatHyperparameter, CategoricalHyperparameter
UniformFloatHyperparameter, Constant

from autosklearn.pipeline.components.base import AutoSklearnClassificationAlgorithm
from autosklearn.pipeline.constants import DENSE, SPARSE, UNSIGNED_DATA, PREDICTIONS
Expand Down Expand Up @@ -67,7 +67,8 @@ def get_hyperparameter_search_space(dataset_properties=None):
n_clusters = UniformIntegerHyperparameter(
name = "n_clusters",
lower = 2,
upper = 20, # ad-hoc
upper = 16, # ad-hoc
q = 2,
default_value = 8
)
contamination = UniformFloatHyperparameter(
Expand All @@ -80,20 +81,19 @@ def get_hyperparameter_search_space(dataset_properties=None):
alpha = UniformFloatHyperparameter(
name = "alpha",
lower = 0.5,
upper = 0.99,
q = 0.01,
upper = 1.0,
q = 0.1,
default_value = 0.9
)
beta = UniformIntegerHyperparameter(
name = "beta",
lower = 1,
upper = 100, # ad-hoc
lower = 2,
upper = 10, # ad-hoc
default_value = 5
)
use_weights = CategoricalHyperparameter(
use_weights = Constant(
name = "use_weights",
choices = [True, False],
default_value = False
value = "False"
)
cs.add_hyperparameters([n_clusters, contamination, alpha, beta, use_weights])

Expand Down
16 changes: 7 additions & 9 deletions src/pyod_models/hbos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ConfigSpace.configuration_space import ConfigurationSpace
from ConfigSpace.hyperparameters import UniformIntegerHyperparameter, \
UniformFloatHyperparameter
UniformFloatHyperparameter, Constant

from autosklearn.pipeline.components.base import AutoSklearnClassificationAlgorithm
from autosklearn.pipeline.constants import DENSE, SPARSE, UNSIGNED_DATA, PREDICTIONS
Expand Down Expand Up @@ -61,24 +61,22 @@ def get_properties(dataset_properties=None):
def get_hyperparameter_search_space(dataset_properties=None):
cs = ConfigurationSpace()

n_bins = UniformIntegerHyperparameter(
n_bins = Constant(
name = "n_bins",
lower = 2, # ad-hoc
upper = 200, # ad-hoc
default_value = 10
value = "auto"
)
alpha = UniformFloatHyperparameter(
name = "alpha",
lower = 0.0,
lower = 0.1,
upper = 1.0,
q = 0.01,
q = 0.1,
default_value = 0.1
)
tol = UniformFloatHyperparameter(
name = "tol",
lower = 0.01,
lower = 0.1,
upper = 1.0,
q = 0.01,
q = 0.1,
default_value = 0.5
)
contamination = UniformFloatHyperparameter(
Expand Down
21 changes: 9 additions & 12 deletions src/pyod_models/iforest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ConfigSpace.configuration_space import ConfigurationSpace
from ConfigSpace.hyperparameters import UniformIntegerHyperparameter, \
UniformFloatHyperparameter, CategoricalHyperparameter
UniformFloatHyperparameter, Constant

from autosklearn.pipeline.components.base import AutoSklearnClassificationAlgorithm
from autosklearn.pipeline.constants import DENSE, SPARSE, UNSIGNED_DATA, PREDICTIONS
Expand Down Expand Up @@ -66,23 +66,21 @@ def get_hyperparameter_search_space(dataset_properties=None):

n_estimators = UniformIntegerHyperparameter(
name = "n_estimators",
lower = 2, # ad-hoc
lower = 5, # ad-hoc
upper = 200, # ad-hoc
q = 5, # step
default_value = 100
)
max_samples = UniformFloatHyperparameter(
name = "max_samples",
lower = 0.1, # ad-hoc
lower = 0.2, # ad-hoc
upper = 1.0,
q = 0.01,
q = 0.2,
default_value = 1.0
)
max_features = UniformFloatHyperparameter(
max_features = Constant(
name = "max_features",
lower = 0.1, # ad-hoc
upper = 1.0,
q = 0.01,
default_value = 1.0
value = 1.0,
)
contamination = UniformFloatHyperparameter(
name = "contamination",
Expand All @@ -91,10 +89,9 @@ def get_hyperparameter_search_space(dataset_properties=None):
q = 0.01,
default_value = 0.1
)
bootstrap = CategoricalHyperparameter(
bootstrap = Constant(
name = "bootstrap",
choices = [True, False],
default_value = False
value = "False"
)
cs.add_hyperparameters([n_estimators, max_samples, max_features, contamination, bootstrap])

Expand Down
13 changes: 5 additions & 8 deletions src/pyod_models/knn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ConfigSpace.configuration_space import ConfigurationSpace
from ConfigSpace.hyperparameters import UniformIntegerHyperparameter, \
UniformFloatHyperparameter, CategoricalHyperparameter
UniformFloatHyperparameter, Constant

from autosklearn.pipeline.components.base import AutoSklearnClassificationAlgorithm
from autosklearn.pipeline.constants import DENSE, SPARSE, UNSIGNED_DATA, PREDICTIONS
Expand Down Expand Up @@ -67,17 +67,14 @@ def get_hyperparameter_search_space(dataset_properties=None):
upper = 100, # ad-hoc
default_value = 5
)
method = CategoricalHyperparameter(
method = Constant(
name = "method",
choices = ['largest', 'mean', 'median'],
default_value = 'largest'
value = 'largest'
)
# order of minkowski distance metric (used by default)
p = UniformIntegerHyperparameter(
p = Constant(
name = "p",
lower = 1, # manhattan
upper = 2, # euclidean
default_value = 2
value = 2 # euclidean
)
contamination = UniformFloatHyperparameter(
name = "contamination",
Expand Down
3 changes: 2 additions & 1 deletion src/pyod_models/lmdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def get_hyperparameter_search_space(dataset_properties=None):
)
n_iter = UniformIntegerHyperparameter(
name = "n_iter",
lower = 1,
lower = 5,
upper = 200, # ad-hoc
q = 5,
default_value = 50
)
dis_measure = CategoricalHyperparameter(
Expand Down
8 changes: 3 additions & 5 deletions src/pyod_models/lof.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ConfigSpace.configuration_space import ConfigurationSpace
from ConfigSpace.hyperparameters import UniformIntegerHyperparameter, \
UniformFloatHyperparameter
UniformFloatHyperparameter, Constant

from autosklearn.pipeline.components.base import AutoSklearnClassificationAlgorithm
from autosklearn.pipeline.constants import DENSE, SPARSE, UNSIGNED_DATA, PREDICTIONS
Expand Down Expand Up @@ -66,11 +66,9 @@ def get_hyperparameter_search_space(dataset_properties=None):
default_value = 20
)
# order of minkowski distance metric (used by default)
p = UniformIntegerHyperparameter(
p = Constant(
name = "p",
lower = 1, # manhattan
upper = 2, # euclidean
default_value = 2
value = 2 # euclidean
)
contamination = UniformFloatHyperparameter(
name = "contamination",
Expand Down

0 comments on commit 3353c3b

Please sign in to comment.