if not isinstance(X, np.ndarray) or not isinstance(Y, np.ndarray) or len(X.shape) > 2 or len(Y.shape) > 2:
raise ValueError("Observation arrays X and Y must be 2d numpy arrays (X type=%s, Y type=%s)" % (type(X), type(Y)))
X = np.atleast_2d(X)
Y = np.atleast_2d(Y)
for x in X:
if not self._within_bounds(x):
raise ValueError("Location %s was not within model bounds." % (x))
if X.shape[0] != Y.shape[0]:
After Change
if not isinstance(X, np.ndarray):
raise ValueError("Type of X must be numpy.ndarray. " +
"Received type {}.".format(type(X)))
if not isinstance(Y, np.ndarray):
raise ValueError("Type of Y must be numpy.ndarray. " +
"Received type {}.".format(type(Y)))
if len(X.shape) != 2 or X.shape[1] != self.input_dim:
raise ValueError("Shape of X must be (n_obs, {}). ".format(self.input_dim) +
"Received shape {}.".format(X.shape))
if len(Y.shape) != 2 or Y.shape[1] != 1:
raise ValueError("Shape of Y must be (n_obs, {}). ".format(self.input_dim) +
"Received shape {}.".format(X.shape))
if X.shape[0] != Y.shape[0]:
raise ValueError("X and Y must contain equal number of observations " +
"(X.shape[0]={}, Y.shape[0]={}).".format(X.shape[0], Y.shape[0]))
for x in X:
if not self._within_bounds(x):
raise ValueError("Location {} was not within model bounds.".format(x))
return X, Y
def update(self, X, Y):
Add (X, Y) as observations, updates GP model.