From 4a08881f5179db5dd1e889faeb0ffd6e3fe1d2e8 Mon Sep 17 00:00:00 2001 From: LucasBoTang Date: Wed, 25 Dec 2024 18:52:09 -0500 Subject: [PATCH] Bug fixed: autosklearn --- pkg/meta.yaml | 2 +- pkg/pyepo/twostage/autosklearnpred.py | 74 +++++++++++++-------------- pkg/setup.py | 2 +- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/pkg/meta.yaml b/pkg/meta.yaml index cb2ff67c..058269a9 100644 --- a/pkg/meta.yaml +++ b/pkg/meta.yaml @@ -3,7 +3,7 @@ package: name: pyepo - version: 0.4.3 + version: 0.4.4 source: path: ./ diff --git a/pkg/pyepo/twostage/autosklearnpred.py b/pkg/pyepo/twostage/autosklearnpred.py index 56fed13a..20403286 100644 --- a/pkg/pyepo/twostage/autosklearnpred.py +++ b/pkg/pyepo/twostage/autosklearnpred.py @@ -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. @@ -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 diff --git a/pkg/setup.py b/pkg/setup.py index 1814c1c7..80483522 100644 --- a/pkg/setup.py +++ b/pkg/setup.py @@ -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