Esempio n. 1
0
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))
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))
Esempio n. 3
0
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], 3)
    assert_equal(cc.stats_c_[1], 7)
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)