def is_train(self, X):
"""Check if an array is the training set.
Parameters
----------
X: array-like
training set to sample observations from.
Returns
----------
self: obj
fitted instance with stored sample.
"""
if not hasattr(self, "train_shape"):
raise NotFittedError("This IdTrain instance is not fitted yet.")
if not self._check_shape(X):
return False
idx = self.sample_idx_
try:
# Grab sample from `X`
sample = X[ix_(idx[0], idx[1])]
return array_equal(sample, self.sample_)
except IndexError:
# If index is out of bounds, X.shape < training_set.shape
# -> X is not the training set
return False
评论列表
文章目录