本文整理汇总了Python中pml.data.model.DataSet.drop_empty_samples方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.drop_empty_samples方法的具体用法?Python DataSet.drop_empty_samples怎么用?Python DataSet.drop_empty_samples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pml.data.model.DataSet
的用法示例。
在下文中一共展示了DataSet.drop_empty_samples方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_drop_empty_samples
# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import drop_empty_samples [as 别名]
def test_drop_empty_samples(self):
df = pd.DataFrame([[1, 2, np.NAN], [np.NAN, np.NAN, np.NAN], [7, 8, 9]])
original = DataSet(df, labels=["a", "b", "c"])
filtered = original.drop_empty_samples()
assert_that(filtered.feature_list(), has_length(3))
assert_that(filtered.num_samples(), equal_to(2))
assert_that(filtered, equals_dataset([[1, 2, np.NAN], [7, 8, 9]]))
assert_that(filtered.get_labels(), contains("a", "c"))
示例2: test_drop_empty_samples_original_unchanged
# 需要导入模块: from pml.data.model import DataSet [as 别名]
# 或者: from pml.data.model.DataSet import drop_empty_samples [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))