def test_nm1_sample_wrong_X(): """Test either if an error is raised when X is different at fitting and sampling""" # Create the object nm1 = NearMiss(random_state=RND_SEED) nm1.fit(X, Y) assert_raises(RuntimeError, nm1.sample, np.random.random((100, 40)), np.array([0] * 50 + [1] * 50))
def test_nm2_sample_wrong_X(): """Test either if an error is raised when X is different at fitting and sampling""" # Create the object nm2 = NearMiss(random_state=RND_SEED, version=VERSION_NEARMISS) nm2.fit(X, Y) assert_raises(RuntimeError, nm2.sample, np.random.random((100, 40)), np.array([0] * 50 + [1] * 50))
def test_nm2_fit(): """Test the fitting method""" # Define the parameter for the under-sampling ratio = 'auto' # Create the object nm2 = NearMiss(ratio=ratio, random_state=RND_SEED, version=VERSION_NEARMISS) # Fit the data nm2.fit(X, Y) # Check if the data information have been computed assert_equal(nm2.min_c_, 0) assert_equal(nm2.maj_c_, 1) assert_equal(nm2.stats_c_[0], 500) assert_equal(nm2.stats_c_[1], 4500)