本文整理汇总了Python中pml.data.model.DataSet.split方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.split方法的具体用法?Python DataSet.split怎么用?Python DataSet.split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pml.data.model.DataSet
的用法示例。
在下文中一共展示了DataSet.split方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_split_0
# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import split [as 别名]
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]]))
示例2: test_split_random
# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import split [as 别名]
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)
示例3: test_unequal_split
# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import split [as 别名]
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]]))
示例4: test_split_labelled
# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import split [as 别名]
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"}))