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


Python SMOTETomek.fit方法代码示例

本文整理汇总了Python中imblearn.combine.SMOTETomek.fit方法的典型用法代码示例。如果您正苦于以下问题:Python SMOTETomek.fit方法的具体用法?Python SMOTETomek.fit怎么用?Python SMOTETomek.fit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imblearn.combine.SMOTETomek的用法示例。


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

示例1: test_sample_wrong_X

# 需要导入模块: from imblearn.combine import SMOTETomek [as 别名]
# 或者: from imblearn.combine.SMOTETomek 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
    sm = SMOTETomek(random_state=RND_SEED)
    sm.fit(X, Y)
    assert_raises(RuntimeError, sm.sample, np.random.random((100, 40)), np.array([0] * 50 + [1] * 50))
开发者ID:yuwin,项目名称:UnbalancedDataset,代码行数:10,代码来源:test_smote_tomek.py

示例2: test_sample_regular

# 需要导入模块: from imblearn.combine import SMOTETomek [as 别名]
# 或者: from imblearn.combine.SMOTETomek import fit [as 别名]
def test_sample_regular():
    """Test sample function with regular SMOTE."""

    # Create the object
    smote = SMOTETomek(random_state=RND_SEED)
    # Fit the data
    smote.fit(X, Y)

    X_resampled, y_resampled = smote.fit_sample(X, Y)

    currdir = os.path.dirname(os.path.abspath(__file__))
    X_gt = np.load(os.path.join(currdir, 'data', 'smote_tomek_reg_x.npy'))
    y_gt = np.load(os.path.join(currdir, 'data', 'smote_tomek_reg_y.npy'))
    assert_array_equal(X_resampled, X_gt)
    assert_array_equal(y_resampled, y_gt)
开发者ID:vivounicorn,项目名称:imbalanced-learn,代码行数:17,代码来源:test_smote_tomek.py

示例3: test_sample_regular_half

# 需要导入模块: from imblearn.combine import SMOTETomek [as 别名]
# 或者: from imblearn.combine.SMOTETomek import fit [as 别名]
def test_sample_regular_half():
    """Test sample function with regular SMOTE and a ratio of 0.5."""

    # Create the object
    ratio = 0.5
    smote = SMOTETomek(ratio=ratio, random_state=RND_SEED)
    # Fit the data
    smote.fit(X, Y)

    X_resampled, y_resampled = smote.fit_sample(X, Y)

    currdir = os.path.dirname(os.path.abspath(__file__))
    X_gt = np.load(os.path.join(currdir, "data", "smote_tomek_reg_x_05.npy"))
    y_gt = np.load(os.path.join(currdir, "data", "smote_tomek_reg_y_05.npy"))
    assert_array_equal(X_resampled, X_gt)
    assert_array_equal(y_resampled, y_gt)
开发者ID:yuwin,项目名称:UnbalancedDataset,代码行数:18,代码来源:test_smote_tomek.py


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