From 3e9b682b6fb2a4302819d93c060f9aec3bc8c686 Mon Sep 17 00:00:00 2001 From: Marius Lindauer Date: Wed, 4 Mar 2020 15:31:31 +0100 Subject: [PATCH 1/2] ADD bilog and GaussianCopula for y-transformation --- smac/runhistory/runhistory2epm.py | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/smac/runhistory/runhistory2epm.py b/smac/runhistory/runhistory2epm.py index 598f7f72f..8bc45bf53 100644 --- a/smac/runhistory/runhistory2epm.py +++ b/smac/runhistory/runhistory2epm.py @@ -3,6 +3,7 @@ import typing import numpy as np +import scipy as sp from smac.tae.execute_ta_run import StatusType from smac.runhistory.runhistory import RunHistory, RunKey, RunValue @@ -10,6 +11,7 @@ from smac.epm.base_imputor import BaseImputor from smac.utils import constants from smac.scenario.scenario import Scenario +from smac.utils.constants import VERY_SMALL_NUMBER __author__ = "Katharina Eggensperger" __copyright__ = "Copyright 2015, ML4AAD" @@ -545,6 +547,57 @@ def transform_response_values(self, values: np.ndarray) -> np.ndarray: return values +class RunHistory2EPM4BiLogCost(RunHistory2EPM4Cost): + """TODO""" + + def transform_response_values(self, values: np.ndarray) -> np.ndarray: + """Transform function response values. + + Transform the response values by using a bilog transformation + + Source: "Scalable Constrained Bayesian Optimization" by Eriksson and Poloczek + https://arxiv.org/pdf/2002.08526.pdf + + Parameters + ---------- + values : np.ndarray + Response values to be transformed. + + Returns + ------- + np.ndarray + """ + return np.sign(values) * np.log(1 + np.abs(values)) + + +class RunHistory2EPM4GaussianCopula(RunHistory2EPM4Cost): + """TODO""" + + def transform_response_values(self, values: np.ndarray) -> np.ndarray: + """Transform function response values. + + Transform the response values by using a Gaussian Copula: + 1. compute quantiles of ECDF on given values + 2. compute inverse Gaussian CDF for these quantiles + + Source: "Scalable Constrained Bayesian Optimization" by Eriksson and Poloczek + https://arxiv.org/pdf/2002.08526.pdf + + Parameters + ---------- + values : np.ndarray + Response values to be transformed. + + Returns + ------- + np.ndarray + """ + # ECDF + quants = [sp.stats.percentileofscore(values, v)/100 - VERY_SMALL_NUMBER for v in values] + # Inverse Gaussian CDF + return np.array([sp.stats.norm.ppf(q) for q in quants]).reshape((-1, 1)) + + class RunHistory2EPM4EIPS(AbstractRunHistory2EPM): """TODO""" From 3fe27f8fd9a9063632e625019f94c275e0c49bba Mon Sep 17 00:00:00 2001 From: Marius Lindauer Date: Wed, 4 Mar 2020 15:34:14 +0100 Subject: [PATCH 2/2] MAINT meta header --- smac/runhistory/runhistory2epm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smac/runhistory/runhistory2epm.py b/smac/runhistory/runhistory2epm.py index 8bc45bf53..05e23e17d 100644 --- a/smac/runhistory/runhistory2epm.py +++ b/smac/runhistory/runhistory2epm.py @@ -13,12 +13,12 @@ from smac.scenario.scenario import Scenario from smac.utils.constants import VERY_SMALL_NUMBER -__author__ = "Katharina Eggensperger" -__copyright__ = "Copyright 2015, ML4AAD" +__author__ = "Katharina Eggensperger, Marius Lindauer" +__copyright__ = "Copyright 2015-2020, AutoML.org" __license__ = "3-clause BSD" __maintainer__ = "Katharina Eggensperger" __email__ = "eggenspk@cs.uni-freiburg.de" -__version__ = "0.0.1" +__version__ = "0.0.3" class AbstractRunHistory2EPM(object):