Beispiel #1
0
def test_compute_statistics():
    R = numpy.array([[1,2],[3,4]],dtype=float)
    M = numpy.array([[1,1],[0,1]])
    (I,J,K,L) = 2, 2, 3, 4
    
    nmtf = NMTF(R,M,K,L)
    
    R_pred = numpy.array([[500,550],[1220,1342]],dtype=float)
    M_pred = numpy.array([[0,0],[1,1]])
    
    MSE_pred = (1217**2 + 1338**2) / 2.0
    R2_pred = 1. - (1217**2+1338**2)/(0.5**2+0.5**2) #mean=3.5
    Rp_pred = 61. / ( math.sqrt(.5) * math.sqrt(7442.) ) #mean=3.5,var=0.5,mean_pred=1281,var_pred=7442,cov=61
    
    assert MSE_pred == nmtf.compute_MSE(M_pred,R,R_pred)
    assert R2_pred == nmtf.compute_R2(M_pred,R,R_pred)
    assert Rp_pred == nmtf.compute_Rp(M_pred,R,R_pred)
Beispiel #2
0
def test_compute_statistics():
    R = numpy.array([[1, 2], [3, 4]], dtype=float)
    M = numpy.array([[1, 1], [0, 1]])
    (I, J, K, L) = 2, 2, 3, 4

    nmtf = NMTF(R, M, K, L)

    R_pred = numpy.array([[500, 550], [1220, 1342]], dtype=float)
    M_pred = numpy.array([[0, 0], [1, 1]])

    MSE_pred = (1217**2 + 1338**2) / 2.0
    R2_pred = 1. - (1217**2 + 1338**2) / (0.5**2 + 0.5**2)  #mean=3.5
    Rp_pred = 61. / (math.sqrt(.5) * math.sqrt(7442.)
                     )  #mean=3.5,var=0.5,mean_pred=1281,var_pred=7442,cov=61

    assert MSE_pred == nmtf.compute_MSE(M_pred, R, R_pred)
    assert R2_pred == nmtf.compute_R2(M_pred, R, R_pred)
    assert Rp_pred == nmtf.compute_Rp(M_pred, R, R_pred)