id_train.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:mlens 作者: flennerhag 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号