Skip to content

Commit

Permalink
use *args, **kwargs schema to centralize default arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBlanke committed May 26, 2024
1 parent 3f79f6e commit 50f652d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class MachineLearningFunction(BaseTestFunction):
def __init__(self, metric, sleep, evaluate_from_data):
super().__init__(metric, sleep)
def __init__(self, *args, sleep=0, evaluate_from_data=False, **kwargs):
super().__init__(*args, sleep, **kwargs)

if evaluate_from_data:
self.sdc = SurfacesDataCollector()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@


class BaseTabular(MachineLearningFunction):
def __init__(self, metric, sleep, evaluate_from_data):
super().__init__(metric, sleep, evaluate_from_data)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@


class BaseClassification(BaseTabular):
metric = "accuracy" # called 'scoring' in sklearn

def __init__(self, metric, sleep, evaluate_from_data):
super().__init__(metric, sleep, evaluate_from_data)
def __init__(self, *args, metric="accuracy", **kwargs):
super().__init__(*args, metric, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ class KNeighborsClassifierFunction(BaseClassification):
cv_default = [2, 3, 4, 5, 8, 10]
dataset_default = [digits_data, wine_data, iris_data]

def __init__(
self,
metric=None,
sleep=0,
evaluate_from_data=False,
):
super().__init__(metric, sleep, evaluate_from_data)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def search_space(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@


class BaseRegression(BaseTabular):
metric = "r2" # called 'scoring' in sklearn

def __init__(self, metric, sleep, evaluate_from_data):
super().__init__(metric, sleep, evaluate_from_data)
def __init__(self, *args, metric="r2", **kwargs):
super().__init__(*args, metric, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ class GradientBoostingRegressorFunction(BaseRegression):
cv_default = [2, 3, 4, 5, 8, 10]
dataset_default = [diabetes_data]

def __init__(
self,
metric=None,
sleep=0,
evaluate_from_data=False,
):
super().__init__(metric, sleep, evaluate_from_data)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def search_space(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ class KNeighborsRegressorFunction(BaseRegression):
cv_default = [2, 3, 4, 5, 8, 10]
dataset_default = [diabetes_data]

def __init__(
self,
metric=None,
sleep=0,
evaluate_from_data=False,
):
super().__init__(metric, sleep, evaluate_from_data)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def search_space(
self,
Expand Down

0 comments on commit 50f652d

Please sign in to comment.