Пример #1
0
             ('rf', rf_clf),
             ('mb', mb_clf),
             ('svm', svm_clf),
             ('sgd', sgd_clf)]
 
 voting_clf = VotingClassifier(
         estimators=estimators,
         voting='hard')
 
 for clf in (log_clf,mlp_clf,rf_clf,mb_clf,svm_clf,sgd_clf,voting_clf):
     clf.fit(X, labels)
     y_pred = clf.predict(X_test)
     print(clf.__class__.__name__, accuracy_score(label_test, y_pred))
     
 clf = BaggingClassifier(
         LogisticRegression(),
         n_estimators=100,
         max_samples=2000, 
         bootstrap=True,
         n_jobs=-1,
         oob_score=True)
 '''
 X = X.toarray()
 X_test = X_test.toarray()
 Y = np.array(labels)
 sgd = SGD()
 sgd.fit(X, Y)
 y_pred = sgd.predict(X_test)
 print(accuracy_score(label_test, y_pred))
 end = time.time()
 print(end - start)