test_comparison.py 文件源码

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

项目:rsmtool 作者: EducationalTestingService 项目源码 文件源码
def test_compute_correlations_between_versions_default_columns():
    df_old = pd.DataFrame({'spkitemid': ['a', 'b', 'c'],
                           'feature1': [1.3, 1.5, 2.1],
                           'feature2': [1.1, 6.2, 2.1],
                           'sc1': [2, 3, 4]})
    df_new = pd.DataFrame({'spkitemid': ['a', 'b', 'c'],
                           'feature1': [-1.3, -1.5, -2.1],
                           'feature2': [1.1, 6.2, 2.1],
                           'sc1': [2, 3, 4]})
    df_cors = compute_correlations_between_versions(df_old, df_new)
    assert_equal(df_cors.get_value('feature1', 'old_new'), -1.0)
    assert_equal(df_cors.get_value('feature2', 'old_new'), 1.0)
    assert_equal(df_cors.get_value('feature1', 'human_old'), pearsonr(df_old['feature1'],
                                                                      df_old['sc1'])[0])
    assert_equal(df_cors.get_value('feature1', 'human_new'), pearsonr(df_new['feature1'],
                                                                      df_new['sc1'])[0])
    assert_equal(df_cors.get_value('feature1', "N"), 3)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号