validation.py 文件源码

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

项目:mlens 作者: flennerhag 项目源码 文件源码
def _check_all_finite(X):
    """General check for all finite values in X."""
    # First try an O(n) time, O(1) space solution for the common case that
    # everything is finite; fall back to O(n) space np.isfinite to prevent
    # false positives from overflow in sum method.
    try:
        if (X.dtype.char in np.typecodes['AllFloat'] and not
                np.isfinite(X.sum()) and not np.isfinite(X).all()):
            return False
        else:
            return True

    except Exception as e:
        warnings.warn('Could not check array for all finite. Ensure X is an'
                      'array type, and consider converting to an ndarray or'
                      'scipy sparse array. Details:\n%r' % e, InputDataWarning)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号