本文整理汇总了Python中splearn.utils.testing.assert_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_equal函数的具体用法?Python assert_equal怎么用?Python assert_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_shape
def test_shape(self):
data = np.arange(4000)
shapes = [(1000, 4),
(200, 20),
(100, 40),
(2000, 2)]
for shape in shapes:
rdd = self.sc.parallelize(data.reshape(shape))
assert_equal(ArrayRDD(rdd).shape, shape)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:9,代码来源:test_rdd.py
示例2: test_unblock
def test_unblock(self):
blocked = BlockRDD(self.generate(1000, 5))
unblocked = blocked.unblock()
assert_is_instance(blocked, BlockRDD)
assert_equal(unblocked.collect(), range(1000))
blocked = BlockRDD(self.generate(1000, 5), dtype=tuple)
unblocked = blocked.unblock()
assert_is_instance(blocked, BlockRDD)
assert_equal(unblocked.collect(), range(1000))
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:10,代码来源:test_rdd.py
示例3: test_same_output
def test_same_output(self):
X, X_rdd = self.make_text_rdd()
local = CountVectorizer()
dist = SparkCountVectorizer()
result_local = local.fit_transform(X).toarray()
result_dist = dist.fit_transform(X_rdd).toarray()
assert_equal(local.vocabulary_, dist.vocabulary_)
assert_array_equal(result_local, result_dist)
开发者ID:KartikPadmanabhan,项目名称:sparkit-learn,代码行数:10,代码来源:test_text.py
示例4: test_ndim
def test_ndim(self):
data = np.arange(4000)
shapes = [(4000),
(1000, 4),
(200, 10, 2),
(100, 10, 2, 2)]
for shape in shapes:
reshaped = data.reshape(shape)
rdd = self.sc.parallelize(reshaped)
assert_equal(ArrayRDD(rdd).ndim, reshaped.ndim)
开发者ID:MiguelPeralvo,项目名称:sparkit-learn,代码行数:10,代码来源:test_rdd.py
示例5: test_same_output
def test_same_output(self):
X, X_rdd = self.make_dict_dataset()
local = DictVectorizer()
dist = SparkDictVectorizer()
result_local = local.fit_transform(X)
result_dist = sp.vstack(dist.fit_transform(X_rdd).collect())
assert_equal(local.vocabulary_, dist.vocabulary_)
assert_array_equal(result_local.toarray(), result_dist.toarray())
开发者ID:HendryLi,项目名称:sparkit-learn,代码行数:10,代码来源:test_dict_vectorizer.py
示例6: test_blocks_number
def test_blocks_number(self):
blocked = BlockRDD(self.generate(1000), bsize=50)
assert_equal(blocked.blocks, 20)
blocked = BlockRDD(self.generate(621), bsize=45)
assert_equal(blocked.blocks, 20)
blocked = BlockRDD(self.generate(100), bsize=4)
assert_equal(blocked.blocks, 30)
blocked = BlockRDD(self.generate(79, 2), bsize=9)
assert_equal(blocked.blocks, 10)
blocked = BlockRDD(self.generate(89, 2), bsize=5)
assert_equal(blocked.blocks, 18)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:11,代码来源:test_rdd.py
示例7: test_length
def test_length(self):
blocked = BlockRDD(self.generate(1000))
assert_equal(len(blocked), 1000)
blocked = BlockRDD(self.generate(100))
assert_equal(len(blocked), 100)
blocked = BlockRDD(self.generate(79))
assert_equal(len(blocked), 79)
blocked = BlockRDD(self.generate(89))
assert_equal(len(blocked), 89)
blocked = BlockRDD(self.generate(62))
assert_equal(len(blocked), 62)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:11,代码来源:test_rdd.py
示例8: test_same_output_sparse
def test_same_output_sparse(self):
X, X_rdd = self.make_dict_dataset()
local = DictVectorizer(sparse=True)
dist = SparkDictVectorizer(sparse=True)
result_local = local.fit_transform(X)
result_dist = dist.fit_transform(X_rdd)
assert_true(check_rdd_dtype(result_dist, (sp.spmatrix,)))
assert_equal(local.vocabulary_, dist.vocabulary_)
assert_array_equal(result_local.toarray(), result_dist.toarray())
开发者ID:KartikPadmanabhan,项目名称:sparkit-learn,代码行数:11,代码来源:test_dict_vectorizer.py
示例9: test_size
def test_size(self):
data = np.arange(4000)
shapes = [(1000, 4),
(200, 20),
(100, 40),
(2000, 2)]
for shape in shapes:
reshaped = data.reshape(shape)
rdd = self.sc.parallelize(reshaped)
size = ArrayRDD(rdd).map(lambda x: x.size).sum()
assert_equal(size, reshaped.size)
assert_equal(ArrayRDD(rdd).size, reshaped.size)
开发者ID:MiguelPeralvo,项目名称:sparkit-learn,代码行数:12,代码来源:test_rdd.py
示例10: test_sum
def test_sum(self):
data = np.arange(400).reshape((100, 4))
rdd = self.sc.parallelize(data)
assert_equal(ArrayRDD(rdd).sum(), data.sum())
assert_array_equal(ArrayRDD(rdd).sum(axis=0), data.sum(axis=0))
assert_array_equal(ArrayRDD(rdd).sum(axis=1), data.sum(axis=1))
data = np.arange(600).reshape((100, 3, 2))
rdd = self.sc.parallelize(data)
assert_equal(ArrayRDD(rdd).sum(), data.sum())
assert_array_equal(ArrayRDD(rdd).sum(axis=0), data.sum(axis=0))
assert_array_equal(ArrayRDD(rdd).sum(axis=1), data.sum(axis=1))
assert_array_equal(ArrayRDD(rdd).sum(axis=2), data.sum(axis=2))
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:13,代码来源:test_rdd.py
示例11: test_transform_with_dtype
def test_transform_with_dtype(self):
data1 = np.arange(400).reshape((100, 4))
data2 = np.arange(200).reshape((100, 2))
rdd1 = self.sc.parallelize(data1, 4)
rdd2 = self.sc.parallelize(data2, 4)
X = DictRDD(rdd1.zip(rdd2), bsize=5)
X2 = X.transform(lambda x: x ** 2, column=0)
assert_equal(X2.dtype, (np.ndarray, np.ndarray))
X2 = X.transform(lambda x: tuple((x ** 2).tolist()), column=0,
dtype=tuple)
assert_equal(X2.dtype, (tuple, np.ndarray))
assert_true(check_rdd_dtype(X2, {0: tuple, 1: np.ndarray}))
X2 = X.transform(lambda x: x ** 2, column=1, dtype=list)
assert_equal(X2.dtype, (np.ndarray, list))
assert_true(check_rdd_dtype(X2, {0: np.ndarray, 1: list}))
X2 = X.transform(lambda a, b: (a ** 2, (b ** 0.5).tolist()),
column=[0, 1], dtype=(np.ndarray, list))
assert_true(check_rdd_dtype(X2, {0: np.ndarray, 1: list}))
X2 = X.transform(lambda b, a: ((b ** 0.5).tolist(), a ** 2),
column=[1, 0], dtype=(list, np.ndarray))
assert_equal(X2.dtype, (np.ndarray, list))
assert_true(check_rdd_dtype(X2, {0: np.ndarray, 1: list}))
开发者ID:KartikPadmanabhan,项目名称:sparkit-learn,代码行数:28,代码来源:test_rdd.py
示例12: test_convert_tolist
def test_convert_tolist(self):
data = np.arange(400)
rdd = self.sc.parallelize(data, 4)
X = ArrayRDD(rdd, 5)
X_list = X.tolist()
assert_is_instance(X_list, list)
assert_equal(X_list, data.tolist())
data = [2, 3, 5, 1, 6, 7, 9, 9]
rdd = self.sc.parallelize(data, 2)
X = ArrayRDD(rdd)
X_list = X.tolist()
assert_is_instance(X_list, list)
assert_equal(X_list, data)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:14,代码来源:test_rdd.py
示例13: test_creation
def test_creation(self):
rdd = self.generate()
blocked = BlockRDD(rdd)
assert_is_instance(blocked, BlockRDD)
assert_equal(blocked.first(), range(10))
assert_equal(blocked.collect(), np.arange(100).reshape(10, 10).tolist())
blocked = BlockRDD(rdd, bsize=4)
assert_is_instance(blocked, BlockRDD)
assert_equal(blocked.first(), range(4))
assert_equal([len(x) for x in blocked.collect()], [4, 4, 2] * 10)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:12,代码来源:test_rdd.py
示例14: test_limit_features
def test_limit_features(self):
X, X_rdd = self.make_text_rdd()
params = [{'min_df': .5},
{'min_df': 2, 'max_df': .9},
{'min_df': 1, 'max_df': .6},
{'min_df': 2, 'max_features': 3}]
for paramset in params:
local = CountVectorizer(**paramset)
dist = SparkCountVectorizer(**paramset)
result_local = local.fit_transform(X)
result_dist = sp.vstack(dist.fit_transform(X_rdd).collect())
assert_equal(local.vocabulary_, dist.vocabulary_)
assert_array_equal(result_local.toarray(), result_dist.toarray())
result_dist = sp.vstack(dist.transform(X_rdd).collect())
assert_array_equal(result_local.toarray(), result_dist.toarray())
开发者ID:HendryLi,项目名称:sparkit-learn,代码行数:20,代码来源:test_text.py
示例15: test_auto_dtype
def test_auto_dtype(self):
x = np.arange(80).reshape((40, 2))
y = tuple(range(40))
z = list(range(40))
x_rdd = self.sc.parallelize(x, 4)
y_rdd = self.sc.parallelize(y, 4)
z_rdd = self.sc.parallelize(z, 4)
expected = (np.arange(20).reshape(10, 2), tuple(range(10)),
list(range(10)))
rdd = DictRDD([x_rdd, y_rdd, z_rdd])
assert_tuple_equal(rdd.first(), expected)
assert_equal(rdd.dtype, (np.ndarray, tuple, tuple))
assert_true(check_rdd_dtype(rdd, {0: np.ndarray, 1: tuple, 2: tuple}))
rdd = DictRDD([x_rdd, y_rdd, z_rdd], columns=('x', 'y', 'z'))
assert_tuple_equal(rdd.first(), expected)
assert_equal(rdd.dtype, (np.ndarray, tuple, tuple))
assert_true(check_rdd_dtype(rdd, {'x': np.ndarray, 'y': tuple,
'z': tuple}))
开发者ID:KartikPadmanabhan,项目名称:sparkit-learn,代码行数:21,代码来源:test_rdd.py
示例16: test_partition_number
def test_partition_number(self):
blocked = BlockRDD(self.generate(1000, 5), bsize=50)
assert_equal(blocked.partitions, 5)
blocked = BlockRDD(self.generate(621, 3), bsize=45)
assert_equal(blocked.partitions, 3)
blocked = BlockRDD(self.generate(100, 10))
assert_equal(blocked.partitions, 10)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:7,代码来源:test_rdd.py
示例17: test_creation
def test_creation(self):
rdd = self.generate()
blocked = BlockRDD(rdd)
assert_is_instance(blocked, BlockRDD)
expected = tuple(range(10))
assert_equal(blocked.first(), expected)
expected = [tuple(v) for v in np.arange(100).reshape(10, 10)]
assert_equal(blocked.collect(), expected)
blocked = BlockRDD(rdd, bsize=4)
assert_is_instance(blocked, BlockRDD)
expected = tuple(range(4))
assert_equal(blocked.first(), expected)
expected = [4, 4, 2] * 10
assert_equal([len(x) for x in blocked.collect()], expected)
开发者ID:MiguelPeralvo,项目名称:sparkit-learn,代码行数:16,代码来源:test_rdd.py
示例18: test_array
def test_array(self):
n_partitions = 10
n_samples = 100
data = self.sc.parallelize([np.array([1]) for i in range(n_samples)],
n_partitions)
blocked_data = block(data)
assert_array_equal(np.ones((10, 1)), blocked_data.first())
blocks = blocked_data.collect()
assert_equal(len(blocks), n_partitions)
assert_array_equal(np.ones((10, 1)), blocks[-1])
assert_equal(sum(len(b) for b in blocks), n_samples)
n_partitions = 17
data = self.sc.parallelize([np.array([1]) for i in range(n_samples)],
n_partitions)
blocked_data = block(data)
assert_array_equal(np.ones((n_samples / n_partitions, 1)),
blocked_data.first())
blocks = blocked_data.collect()
assert_equal(len(blocks), n_partitions)
assert_equal(sum(len(b) for b in blocks), n_samples)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:21,代码来源:test_rdd.py
示例19: test_dtype
def test_dtype(self):
n_partitions = 10
n_samples = 100
data = self.sc.parallelize(["lorem" for i in range(n_samples)],
n_partitions)
blocked_data = block(data, dtype=list)
assert_array_equal(["lorem"] * 10, blocked_data.first())
blocks = blocked_data.collect()
assert_equal(len(blocks), n_partitions)
assert_array_equal(["lorem"] * 10, blocks[-1])
assert_equal(sum(len(b) for b in blocks), n_samples)
n_partitions = 17
data = self.sc.parallelize([1 for i in range(n_samples)],
n_partitions)
blocked_data = block(data, dtype=tuple)
assert_array_equal(tuple([1] * (n_samples / n_partitions)),
blocked_data.first())
blocks = blocked_data.collect()
assert_equal(len(blocks), n_partitions)
assert_equal(sum(len(b) for b in blocks), n_samples)
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:21,代码来源:test_rdd.py
示例20: test_tolist
def test_tolist(self):
blocked = BlockRDD(self.generate(1000, 5))
unblocked = blocked.tolist()
assert_is_instance(blocked, BlockRDD)
assert_equal(unblocked, range(1000))
blocked = BlockRDD(self.generate(1000, 5), dtype=tuple)
unblocked = blocked.tolist()
assert_is_instance(blocked, BlockRDD)
assert_equal(unblocked, range(1000))
blocked = BlockRDD(self.generate(1000, 5), dtype=np.array)
unblocked = blocked.tolist()
assert_is_instance(blocked, BlockRDD)
assert_equal(unblocked, range(1000))
开发者ID:schevalier,项目名称:sparkit-learn,代码行数:15,代码来源:test_rdd.py
注:本文中的splearn.utils.testing.assert_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论