def test_parallel_predict():
 clf1 = LogisticRegression(random_state=123)
 clf2 = RandomForestClassifier(random_state=123)
 clf3 = GaussianNB()
 X = np.array([[(-1.1), (-1.5)], [(-1.2), (-1.4)], [(-3.4), (-2.2)], [1.1, 1.2]])
 y = np.array([1, 1, 2, 2])
 eclf1 = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2), ('gnb', clf3)], voting='soft', n_jobs=1).fit(X, y)
 eclf2 = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2), ('gnb', clf3)], voting='soft', n_jobs=2).fit(X, y)
 assert_array_equal(eclf1.predict(X), eclf2.predict(X))
 assert_array_equal(eclf1.predict_proba(X), eclf2.predict_proba(X))

def test_parallel_predict ( ) : clf1 = LogisticRegression ( random_state = 123 ) clf2 = RandomForestClassifier ( random_state = 123 ) clf3 = GaussianNB ( ) X = np . array ( [ [ ( - 1.1 ) , ( - 1.5 ) ] , [ ( - 1.2 ) , ( - 1.4 ) ] , [ ( - 3.4 ) , ( - 2.2 ) ] , [ 1.1 , 1.2 ] ] ) y = np . array ( [ 1 , 1 , 2 , 2 ] ) eclf1 = VotingClassifier ( estimators = [ ( 'lr' , clf1 ) , ( 'rf' , clf2 ) , ( 'gnb' , clf3 ) ] , voting = 'soft' , n_jobs = 1 ) . fit ( X , y ) eclf2 = VotingClassifier ( estimators = [ ( 'lr' , clf1 ) , ( 'rf' , clf2 ) , ( 'gnb' , clf3 ) ] , voting = 'soft' , n_jobs = 2 ) . fit ( X , y ) assert_array_equal ( eclf1 . predict ( X ) , eclf2 . predict ( X ) ) assert_array_equal ( eclf1 . predict_proba ( X ) , eclf2 . predict_proba ( X ) )
check parallel backend of votingclassifier on toy dataset .