def test_iforest_performance():
 rng = check_random_state(2)
 X = (0.3 * rng.randn(120, 2))
 X_train = np.r_[((X + 2), (X - 2))]
 X_train = X[:100]
 X_outliers = rng.uniform(low=(-4), high=4, size=(20, 2))
 X_test = np.r_[(X[100:], X_outliers)]
 y_test = np.array((([0] * 20) + ([1] * 20)))
 clf = IsolationForest(max_samples=100, random_state=rng).fit(X_train)
 y_pred = (- clf.decision_function(X_test))
 assert_greater(roc_auc_score(y_test, y_pred), 0.98)

def test_iforest_performance ( ) : rng = check_random_state ( 2 ) X = ( 0.3 * rng . randn ( 120 , 2 ) ) X_train = np . r_ [ ( ( X + 2 ) , ( X - 2 ) ) ] X_train = X [ : 100 ] X_outliers = rng . uniform ( low = ( - 4 ) , high = 4 , size = ( 20 , 2 ) ) X_test = np . r_ [ ( X [ 100 : ] , X_outliers ) ] y_test = np . array ( ( ( [ 0 ] * 20 ) + ( [ 1 ] * 20 ) ) ) clf = IsolationForest ( max_samples = 100 , random_state = rng ) . fit ( X_train ) y_pred = ( - clf . decision_function ( X_test ) ) assert_greater ( roc_auc_score ( y_test , y_pred ) , 0.98 )
test isolation forest performs well .