本文整理匯總了Python中imblearn.under_sampling.ClusterCentroids.fit方法的典型用法代碼示例。如果您正苦於以下問題:Python ClusterCentroids.fit方法的具體用法?Python ClusterCentroids.fit怎麽用?Python ClusterCentroids.fit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類imblearn.under_sampling.ClusterCentroids
的用法示例。
在下文中一共展示了ClusterCentroids.fit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_sample_wrong_X
# 需要導入模塊: from imblearn.under_sampling import ClusterCentroids [as 別名]
# 或者: from imblearn.under_sampling.ClusterCentroids import fit [as 別名]
def test_sample_wrong_X():
"""Test either if an error is raised when X is different at fitting
and sampling"""
# Create the object
cc = ClusterCentroids(random_state=RND_SEED)
cc.fit(X, Y)
assert_raises(RuntimeError, cc.sample, np.random.random((100, 40)),
np.array([0] * 50 + [1] * 50))
示例2: test_cc_fit
# 需要導入模塊: from imblearn.under_sampling import ClusterCentroids [as 別名]
# 或者: from imblearn.under_sampling.ClusterCentroids import fit [as 別名]
def test_cc_fit():
"""Test the fitting method"""
# Define the parameter for the under-sampling
ratio = 'auto'
# Create the object
cc = ClusterCentroids(ratio=ratio, random_state=RND_SEED)
# Fit the data
cc.fit(X, Y)
# Check if the data information have been computed
assert_equal(cc.min_c_, 0)
assert_equal(cc.maj_c_, 1)
assert_equal(cc.stats_c_[0], 500)
assert_equal(cc.stats_c_[1], 4500)