コード例 #1
0
ファイル: tests.py プロジェクト: esantorella/tva
def test_get_mc1_precision():
    var_epsilon = abs(np.random.random())
    std_theta = abs(np.random.random())
    n_classes = 100
    
    errors = []
    precisions = []
    
    for class_ in range(n_classes):
        mu_0 = np.random.random()
        mu_1 = np.random.random()
        n_students = 20
        df = construct_class_df(0, class_, n_students, std_theta, mu_0, mu_1, var_epsilon)
        m_c1 = calculate_va_continuous.get_mc1(df)
        
        errors.append(m_c1 - mu_1)
        precisions.append(calculate_va_continuous.get_mc1_precision(calculate_va_continuous.collapse(df), var_epsilon))
    
    check_calibration(np.array(errors), np.array(precisions))
コード例 #2
0
ファイル: tests.py プロジェクト: esantorella/tva
def test_get_mc0_precision():
    std_theta = 1
    var_epsilon = 1   
    n_students = 20
    n_classes = 10
    errors = np.zeros(n_classes)    
    precisions = np.zeros(n_classes)
    
    for class_ in range(n_classes):
        mu_1 = np.random.normal()
        mu_0 =  np.random.normal()

        df = construct_class_df(0, 0, n_students, std_theta, mu_0, mu_1, var_epsilon)
        
        collapsed = calculate_va_continuous.collapse(df)
        collapsed['m_c1'] = calculate_va_continuous.get_mc1(df)
        mc_0 = calculate_va_continuous.get_mc0(collapsed)
        
        errors[class_] = mc_0 - mu_0
        precisions[class_] = calculate_va_continuous.get_mc0_precision(std_theta**2, var_epsilon, df['continuous var'].values)
        
    check_calibration(errors, precisions)
コード例 #3
0
ファイル: tests.py プロジェクト: esantorella/tva
def test_get_mc0():
    var_epsilon = abs(np.random.normal())
    std_theta = abs(np.random.normal())    
    n_students = 25
    n_classes = 1000

    errors = np.zeros(n_classes)    
    for class_ in range(n_classes):
        mu_1 = np.random.normal()
        mu_0 =  np.random.normal()
    
        df = construct_class_df(0, 0, n_students, std_theta, mu_0, mu_1, var_epsilon)
        df = calculate_va_continuous.collapse(df)
        df['m_c1'] = mu_1   # Just assume this is correctly estimated
        mc_0 = calculate_va_continuous.get_mc0(df)
        errors[class_] = mc_0 - mu_0
        
    error_se = (np.var(errors) / n_classes)**(.5)
    mean_error = np.mean(errors)

    assert mean_error > -2 * error_se
    assert mean_error < 2 * error_se