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


Python model.DataSet类代码示例

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


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

示例1: test_get_row

 def test_get_row(self):
     dataset = DataSet([[1, 2], [3, 4], [5, 6], [7, 8]])
     row = dataset.get_row(1)
     assert_that(row.values, contains(3, 4))
     # check that changes made to selected row are reflected in original
     row[:] = 1
     assert_that(dataset.get_row(1), contains(1, 1))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:7,代码来源:test_model.py

示例2: test_has_missing_values

 def test_has_missing_values(self):
     dataset1 = DataSet([[4.2, np.NaN, 3.1], [2.5, 1.9, np.NaN], 
                         [1.1, 1.2, 1.7]])
     self.assertTrue(dataset1.has_missing_values())
     
     dataset2 = DataSet([[4.2, 3.9, 3.1], [2.5, 1.9, 2.2], [1.1, 1.2, 1.7]])
     self.assertFalse(dataset2.has_missing_values())
开发者ID:antoniograndinetti,项目名称:pml,代码行数:7,代码来源:test_model.py

示例3: test_split_random

 def test_split_random(self):
     dataset = DataSet([[1, 2], [3, 4], [5, 6], [7, 8]])
     first, second = dataset.split(0.5, random=True)
     # since the split is random, can't assert that first or second 
     # contain particular rows, just the number of rows
     self.assertEqual(first.num_samples(), 2)
     self.assertEqual(second.num_samples(), 2)
开发者ID:antoniograndinetti,项目名称:pml,代码行数:7,代码来源:test_model.py

示例4: test_unequal_split

 def test_unequal_split(self):
     dataset = DataSet([[1, 2], [3, 4], [5, 6], [7, 8]])
     first, second = dataset.split(0.3)
     self.assertEqual(first.num_samples(), 1)
     assert_that(first, equals_dataset([[1, 2]]))
     self.assertEqual(second.num_samples(), 3)
     assert_that(second, equals_dataset([[3, 4], [5, 6], [7, 8]]))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:7,代码来源:test_model.py

示例5: test_split_0

 def test_split_0(self):
     dataset = DataSet([[1, 2], [3, 4], [5, 6], [7, 8]])
     first, second = dataset.split(0)
     self.assertEqual(first.num_samples(), 0)
     assert_that(first, equals_dataset([]))
     self.assertEqual(second.num_samples(), 4)
     assert_that(second, equals_dataset([[1, 2], [3, 4], [5, 6], [7, 8]]))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:7,代码来源:test_model.py

示例6: test_get_label_value_counts

 def test_get_label_value_counts(self):
     dataset = DataSet([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]], 
                       labels=["a", "b", "b", "c", "a", "b"])
     expected = {"a": 2, "b": 3, "c": 1}
     value_counts = dataset.get_label_value_counts()
     assert_that(value_counts, equals_series(expected))
     assert_that(value_counts.index, contains("b", "a", "c"))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:7,代码来源:test_model.py

示例7: test_slice_features_list_indices

 def test_slice_features_list_indices(self):
     df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     labels = ["m", "f", "m"]
     dataset = DataSet(df, labels=labels)
     sliced = dataset.slice_features([1, 2])
     assert_that(sliced, equals_dataset([[2, 3], [5, 6], [8, 9]]))
     assert_that(sliced.feature_list(), contains(1, 2))
     assert_that(sliced.get_labels(), contains(*labels))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:8,代码来源:test_model.py

示例8: test_split_labelled

 def test_split_labelled(self):
     dataset = DataSet([[1, 2], [3, 4], [5, 6], [7, 8]], 
                       labels=["b", "b", "b", "a"])
     first, second = dataset.split(0.5)
     self.assertTrue(first.is_labelled())
     assert_that(first.get_labels(), equals_series({0: "b", 1: "b"}))
     self.assertTrue(second.is_labelled())
     assert_that(second.get_labels(), equals_series({2: "b", 3: "a"}))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:8,代码来源:test_model.py

示例9: test_filter_by_feature_value_with_labels

 def test_filter_by_feature_value_with_labels(self):
     features = ["name", "hair colour"]
     df = pd.DataFrame([["Bill", "brown"], ["Bob", "black"], 
                        ["Jim", "brown"]], columns=features)
     dataset = DataSet(df, labels=["SENG", "SENG", "CENG"])
     filtered = dataset.value_filter("hair colour", "brown")
     assert_that(filtered.get_labels(), 
                 equals_series({0: "SENG", 2: "CENG"}))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:8,代码来源:test_model.py

示例10: test_bin_feature

 def test_bin_feature(self):
     df = pd.DataFrame([[0, 1], [7, 2], [6, 3]], 
                       columns=["MATH100", "PHYS125"])
     dataset = DataSet(df)
     
     dataset.bin("MATH100", [4, 7])
     
     assert_that(dataset, equals_dataset([[0, 1], [2, 2], [1, 3]]))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:8,代码来源:test_model.py

示例11: test_get_labelled_data_frame

    def test_get_labelled_data_frame(self):
        dataset = DataSet([[1, 2], [3, 4], [5, 6], [7, 8]], 
                          labels=pd.Series(["b", "b", "b", "a"]))
        df = dataset.get_labelled_data_frame()

        # TODO: non-numeric values in DataFrame matcher
        expected = [[1, 2, "b"], [3, 4, "b"], [5, 6, "b"], [7, 8, "a"]]
        for i in range(len(expected)):
            self.assertTrue(df.ix[i].tolist(), expected[i])
开发者ID:antoniograndinetti,项目名称:pml,代码行数:9,代码来源:test_model.py

示例12: test_get_row_by_id

 def test_get_row_by_id(self):
     df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 
                       index=["V01", "V02", "V03"])
     dataset = DataSet(df)
     sample = dataset.get_row("V02")
     assert_that(sample, contains(4, 5, 6))
     # make sure position based index is still usable
     sample = dataset.get_row(1)
     assert_that(sample, contains(4, 5, 6))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:9,代码来源:test_model.py

示例13: test_copy

 def test_copy(self):
     dataset1 = DataSet([[1, 2], [3, 4]], labels=pd.Series(["a", "b"]))
     dataset2 = dataset1.copy()
     dataset2.set_column(1, pd.Series([4, 5]))
     
     assert_that(dataset2, equals_dataset([[1, 4], [3, 5]]))
     assert_that(dataset2.get_labels(), equals_series({0: "a", 1: "b"}))
     assert_that(dataset1, equals_dataset([[1, 2], [3, 4]]))
     assert_that(dataset2.get_labels(), equals_series({0: "a", 1: "b"}))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:9,代码来源:test_model.py

示例14: test_copy_no_labels

 def test_copy_no_labels(self):
     dataset1 = DataSet([[1, 2], [3, 4]])
     dataset2 = dataset1.copy()
     dataset2.set_column(1, pd.Series([4, 5]))
     
     assert_that(dataset2, equals_dataset([[1, 4], [3, 5]]))
     self.assertFalse(dataset2.is_labelled())
     assert_that(dataset1, equals_dataset([[1, 2], [3, 4]]))
     self.assertFalse(dataset1.is_labelled())
开发者ID:antoniograndinetti,项目名称:pml,代码行数:9,代码来源:test_model.py

示例15: test_slice_features_list_string

 def test_slice_features_list_string(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"])
     assert_that(sliced, equals_dataset([[1, 2], [4, 5], [7, 8]]))
     assert_that(sliced.feature_list(), contains("weight", "height"))
     assert_that(sliced.get_labels(), contains(*labels))
开发者ID:antoniograndinetti,项目名称:pml,代码行数:9,代码来源:test_model.py


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