当前位置: 首页>>代码示例>>Python>>正文


Python sputils.isdense方法代码示例

本文整理汇总了Python中scipy.sparse.sputils.isdense方法的典型用法代码示例。如果您正苦于以下问题:Python sputils.isdense方法的具体用法?Python sputils.isdense怎么用?Python sputils.isdense使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.sparse.sputils的用法示例。


在下文中一共展示了sputils.isdense方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: f1_per_sample

# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isdense [as 别名]
def f1_per_sample(y_true, y_pred):
    if isdense(y_true) or isdense(y_pred):
        y_true = sp.csr_matrix(y_true)
        y_pred = sp.csr_matrix(y_pred)
    sum_axis = 1
    true_and_pred = y_true.multiply(y_pred)
    tp_sum = count_nonzero(true_and_pred, axis=sum_axis)
    pred_sum = count_nonzero(y_pred, axis=sum_axis)
    true_sum = count_nonzero(y_true, axis=sum_axis)

    with np.errstate(divide='ignore', invalid='ignore'):
        precision = _prf_divide(tp_sum, pred_sum)
        recall = _prf_divide(tp_sum, true_sum)
        f_score = (2 * precision * recall / (1 * precision + recall))
        f_score[tp_sum == 0] = 0.0

    return f_score 
开发者ID:quadflor,项目名称:Quadflor,代码行数:19,代码来源:metrics.py

示例2: get_inv_matvec

# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isdense [as 别名]
def get_inv_matvec(M, symmetric=False, tol=0):
    if isdense(M):
        return LuInv(M).matvec
    elif isspmatrix(M):
        if isspmatrix_csr(M) and symmetric:
            M = M.T
        return SpLuInv(M).matvec
    else:
        return IterInv(M, tol=tol).matvec 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:11,代码来源:arpack.py

示例3: get_OPinv_matvec

# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isdense [as 别名]
def get_OPinv_matvec(A, M, sigma, symmetric=False, tol=0):
    if sigma == 0:
        return get_inv_matvec(A, symmetric=symmetric, tol=tol)

    if M is None:
        #M is the identity matrix
        if isdense(A):
            if (np.issubdtype(A.dtype, np.complexfloating)
                    or np.imag(sigma) == 0):
                A = np.copy(A)
            else:
                A = A + 0j
            A.flat[::A.shape[1] + 1] -= sigma
            return LuInv(A).matvec
        elif isspmatrix(A):
            A = A - sigma * eye(A.shape[0])
            if symmetric and isspmatrix_csr(A):
                A = A.T
            return SpLuInv(A.tocsc()).matvec
        else:
            return IterOpInv(_aslinearoperator_with_dtype(A),
                              M, sigma, tol=tol).matvec
    else:
        if ((not isdense(A) and not isspmatrix(A)) or
                (not isdense(M) and not isspmatrix(M))):
            return IterOpInv(_aslinearoperator_with_dtype(A),
                              _aslinearoperator_with_dtype(M),
                              sigma, tol=tol).matvec
        elif isdense(A) or isdense(M):
            return LuInv(A - sigma * M).matvec
        else:
            OP = A - sigma * M
            if symmetric and isspmatrix_csr(OP):
                OP = OP.T
            return SpLuInv(OP.tocsc()).matvec


# ARPACK is not threadsafe or reentrant (SAVE variables), so we need a
# lock and a re-entering check. 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:41,代码来源:arpack.py

示例4: test_isdense

# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isdense [as 别名]
def test_isdense(self):
        assert_equal(sputils.isdense(np.array([1])),True)
        assert_equal(sputils.isdense(np.matrix([1])),True) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:test_sputils.py

示例5: get_OPinv_matvec

# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isdense [as 别名]
def get_OPinv_matvec(A, M, sigma, symmetric=False, tol=0):
    if sigma == 0:
        return get_inv_matvec(A, symmetric=symmetric, tol=tol)

    if M is None:
        #M is the identity matrix
        if isdense(A):
            if (np.issubdtype(A.dtype, np.complexfloating)
                or np.imag(sigma) == 0):
                A = np.copy(A)
            else:
                A = A + 0j
            A.flat[::A.shape[1] + 1] -= sigma
            return LuInv(A).matvec
        elif isspmatrix(A):
            A = A - sigma * eye(A.shape[0])
            if symmetric and isspmatrix_csr(A):
                A = A.T
            return SpLuInv(A.tocsc()).matvec
        else:
            return IterOpInv(_aslinearoperator_with_dtype(A),
                              M, sigma, tol=tol).matvec
    else:
        if ((not isdense(A) and not isspmatrix(A)) or
            (not isdense(M) and not isspmatrix(M))):
            return IterOpInv(_aslinearoperator_with_dtype(A),
                              _aslinearoperator_with_dtype(M),
                              sigma, tol=tol).matvec
        elif isdense(A) or isdense(M):
            return LuInv(A - sigma * M).matvec
        else:
            OP = A - sigma * M
            if symmetric and isspmatrix_csr(OP):
                OP = OP.T
            return SpLuInv(OP.tocsc()).matvec 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:37,代码来源:arpack.py

示例6: test_isdense

# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isdense [as 别名]
def test_isdense(self):
        assert_equal(sputils.isdense(np.array([1])), True)
        assert_equal(sputils.isdense(np.matrix([1])), True) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:5,代码来源:test_sputils.py


注:本文中的scipy.sparse.sputils.isdense方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。