template.py 文件源码

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

项目:project-template 作者: scikit-learn-contrib 项目源码 文件源码
def predict(self, X):
        """ A reference implementation of a prediction for a classifier.

        Parameters
        ----------
        X : array-like of shape = [n_samples, n_features]
            The input samples.

        Returns
        -------
        y : array of int of shape = [n_samples]
            The label for each sample is the label of the closest sample
            seen udring fit.
        """
        # Check is fit had been called
        check_is_fitted(self, ['X_', 'y_'])

        # Input validation
        X = check_array(X)

        closest = np.argmin(euclidean_distances(X, self.X_), axis=1)
        return self.y_[closest]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号