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


Python SampleData.set_of_feature_sets方法代码示例

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


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

示例1: test_load

# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import set_of_feature_sets [as 别名]
    def test_load(self):
        data = SampleData.set_of_feature_sets()
        manager = FeatureMatrix.FeatureMatrixManager(data, standardize=False)

        a = manager.data["a"]
        self.assertEqual(len(a), 3)
        numpy.testing.assert_almost_equal(a["1"], [0.0, 0.1, 0.3, 0.0])
        numpy.testing.assert_almost_equal(a["2"], [0.0, 0.1, 0.0, 0.1])
        numpy.testing.assert_almost_equal(a["3"], [0.0, 0.1, 0.2, 0.1])

        a_m, a_labels = manager.get_feature_product("a")
        numpy.testing.assert_almost_equal(a_m, EXPECTED_A)
        self.assertEqual(a_labels, ["1", "2", "3"])

        a_m, a_labels = manager.get_feature_product("a", center=True)
        numpy.testing.assert_almost_equal(a_m, numpy.cov([a["1"], a["2"], a["3"]]))
        self.assertEqual(a_labels, ["1", "2", "3"])

        b = manager.data["b"]
        self.assertEqual(len(b), 3)
        numpy.testing.assert_almost_equal(b["1"], [1.0, 0.5, 1.2, 0.9])
        numpy.testing.assert_almost_equal(b["2"], [1.0, 1.0, 1.2, 1.0])
        numpy.testing.assert_almost_equal(b["3"], [1.0, 0.75, 1.2, 0.95])

        b_m, b_labels = manager.get_feature_product("b")
        numpy.testing.assert_almost_equal(b_m, EXPECTED_B)
        self.assertEqual(b_labels, ["1", "2", "3"])

        d = manager.data["d"]
        self.assertEqual(len(d), 2)
        numpy.testing.assert_almost_equal(d["2"], [0.5, 0.7, 0.6, 0.8])
        numpy.testing.assert_almost_equal(d["3"], [0.9, 0.9, 0.8, 1.1])

        d_m, d_labels = manager.get_feature_product("d")
        numpy.testing.assert_almost_equal(d_m, EXPECTED_D)
        self.assertEqual(d_labels, ["2", "3"])

        e_m, e_labels = manager.get_feature_product("e")
        numpy.testing.assert_almost_equal(e_m, [[ 0.3726]])
        self.assertEqual(e_labels, ["2"])
开发者ID:torstees,项目名称:MetaXcan,代码行数:42,代码来源:test_feature_matrix.py


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