Source code for desdeo_problem.surrogatemodels.SurrogateModels

from abc import ABC, abstractmethod
from typing import Tuple

import numpy as np
from sklearn.gaussian_process import GaussianProcessRegressor as GPR


[docs]class ModelError(Exception): """Raised when an error related to the surrogate models classes is encountered. """
# TODO: Add more sklearn methods here
[docs]class BaseRegressor(ABC):
[docs] @abstractmethod def fit(self, X: np.ndarray, y: np.ndarray): pass
[docs] @abstractmethod def predict(self, X: np.ndarray) -> Tuple[np.ndarray, np.ndarray]: pass
[docs]class GaussianProcessRegressor(GPR, BaseRegressor): def __init__(self, **kwargs): super().__init__(**kwargs)
[docs] def predict(self, X: np.ndarray): return super().predict(X, return_std=True)