Skip to content

Commit

Permalink
Bug fixed: autosklearn
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasBoTang committed Dec 25, 2024
1 parent dac9e7b commit 4a08881
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pkg/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package:
name: pyepo
version: 0.4.3
version: 0.4.4

source:
path: ./
Expand Down
74 changes: 36 additions & 38 deletions pkg/pyepo/twostage/autosklearnpred.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,6 @@

from pyepo.metric import makeAutoSkScorer

class NoPreprocessing(AutoSklearnPreprocessingAlgorithm):
"""
This is class of NoPreprocessing component for auto-sklearn
"""
def __init__(self, **kwargs):
"""
This preprocessors does not change the data
"""
# Some internal checks makes sure parameters are set
for key, val in kwargs.items():
setattr(self, key, val)

def fit(self, X, Y=None):
return self

def transform(self, X):
return X

@staticmethod
def get_properties(dataset_properties=None):
return {
"shortname": "NoPreprocessing",
"name": "NoPreprocessing",
"handles_regression": True,
"handles_classification": True,
"handles_multiclass": True,
"handles_multilabel": True,
"handles_multioutput": True,
"is_deterministic": True,
"input": (SPARSE, DENSE, UNSIGNED_DATA),
"output": (INPUT,)
}

@staticmethod
def get_hyperparameter_search_space(dataset_properties=None):
return ConfigurationSpace() # Return an empty configuration as there is None


def autoSklearnPred(optmodel, seed, timelimit, metric="mse"):
"""
Two-stage prediction and optimization with auto-sklearn.
Expand All @@ -70,6 +32,42 @@ def autoSklearnPred(optmodel, seed, timelimit, metric="mse"):
# error
if not _HAS_AUTO:
raise ImportError("Autosklearn is not installed. Please install autosklearn to use this feature.")
class NoPreprocessing(AutoSklearnPreprocessingAlgorithm):
"""
This is class of NoPreprocessing component for auto-sklearn
"""
def __init__(self, **kwargs):
"""
This preprocessors does not change the data
"""
# Some internal checks makes sure parameters are set
for key, val in kwargs.items():
setattr(self, key, val)

def fit(self, X, Y=None):
return self

def transform(self, X):
return X

@staticmethod
def get_properties(dataset_properties=None):
return {
"shortname": "NoPreprocessing",
"name": "NoPreprocessing",
"handles_regression": True,
"handles_classification": True,
"handles_multiclass": True,
"handles_multilabel": True,
"handles_multioutput": True,
"is_deterministic": True,
"input": (SPARSE, DENSE, UNSIGNED_DATA),
"output": (INPUT,)
}

@staticmethod
def get_hyperparameter_search_space(dataset_properties=None):
return ConfigurationSpace() # Return an empty configuration as there is None
# add NoPreprocessing component to auto-sklearn.
data_preprocessing.add_preprocessor(NoPreprocessing)
# get metrics
Expand Down
2 changes: 1 addition & 1 deletion pkg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
# version
version = "0.4.3",
version = "0.4.4",
# Github repo
url = "https://github.com/khalil-research/PyEPO",
# author name
Expand Down

0 comments on commit 4a08881

Please sign in to comment.