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


Python DataSet.get_labels方法代码示例

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


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

示例1: test_drop_empty_samples_original_unchanged

# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import get_labels [as 别名]
    def test_drop_empty_samples_original_unchanged(self):
        data_list = [[1, 2, np.NAN], [np.NAN, np.NAN, np.NAN], [7, 8, 9]]
        label_list = ["a", "b", "c"]
        original = DataSet(pd.DataFrame(data_list), labels=label_list)

        filtered = original.drop_empty_samples()
        filtered.set_column(0, [-1, -1])
        filtered.labels[0] = "z"

        assert_that(original, equals_dataset(data_list))
        assert_that(original.get_labels(), contains(*label_list))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:13,代码来源:test_model.py

示例2: test_slice_features_original_unchanged

# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import get_labels [as 别名]
    def test_slice_features_original_unchanged(self):
        df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]],
                          columns=["weight", "height", "age"])
        labels = ["m", "f", "m"]
        dataset = DataSet(df, labels=labels)
        sliced = dataset.slice_features(["weight", "height"])

        # Modify sliced data
        sliced.set_column("weight", [0, 0, 0])
        sliced.labels[0] = "x"

        # Check that it was indeed changed
        assert_that(sliced.get_column("weight"), contains(0, 0, 0))
        assert_that(sliced.get_labels(), contains("x", "f", "m"))

        # Verify it was not changed in the original dataset
        assert_that(dataset.get_column("weight"), contains(1, 4, 7))
        assert_that(dataset.get_labels(), contains(*labels))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:20,代码来源:test_model.py

示例3: test_combine_labels

# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import get_labels [as 别名]
 def test_combine_labels(self):
     dataset = DataSet([[1, 2], [3, 4], [5, 6]], 
                       labels=pd.Series(["cat", "crow", "pidgeon"]))
     dataset.combine_labels(["crow", "pidgeon"], "bird")
     labels = dataset.get_labels()
     assert_that(labels, equals_series({0: "cat", 1: "bird", 2: "bird"}))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:8,代码来源:test_model.py


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