import time
from sklearn.neural_network import MLPClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
from sklearn.metrics import accuracy_score

classifiers = [
    [KNeighborsClassifier(3), 'KNeighbors'],
    [SVC(kernel="linear", C=0.025), 'SVC_linear'],
    [SVC(gamma=2, C=1), 'SVC'],
    [DecisionTreeClassifier(max_depth=5), 'DecisionTree'],
    [RandomForestClassifier(max_depth=5, n_estimators=100, max_features=1),
        'RandomForest'],
    [MLPClassifier(alpha=1, max_iter=1000), 'MPL'],
    [AdaBoostClassifier(), 'AdaBoost'],
    [GaussianNB(), 'GaussianNB'],
    [QuadraticDiscriminantAnalysis(), 'QuadraticDiscriminantAnalysis']]

for clf, clf_name in classifiers:
    t0 = time.time()
    clf.fit(X_train, y_train)
    metric = accuracy_score(y_valid, clf.predict(X_valid))*100
    print(f'{clf_name}: {metric:.1f}%  Completed in {time.time()-t0:.2f}s')

T-POT

# !pip install tpot
from tpot import TPOTClassifier
tpot = TPOTClassifier(generations=100,
    population_size=100,
    offspring_size=None, mutation_rate=0.9,
    crossover_rate=0.1,
    scoring='accuracy', cv=5,
    subsample=1.0, n_jobs=1,
    max_time_mins=None, max_eval_time_mins=5,
    random_state=None,
    warm_start=False,
    early_stop=None,
    verbosity=0,
    disable_update_check=False)
tpot.fit(X_train, y_train)

y_pred = tpot.predict(X_valid)
accuracy_score(y_pred, y_valid)

H2O on Colab

! apt-get install default-jre
!java -version
! pip install h2o

import h2o
from h2o.automl import H2OAutoML

h2o.init()
train = h2o.import_file('train.csv')
valid = h2o.import_file('valid.csv')
y = "y"
x = ["X"]
train[y] = train[y].asfactor()
valid[y] = valid[y].asfactor()
aml = H2OAutoML(max_runtime_secs = 120)
aml.train(x = x, y = y, training_frame = train)
aml.leaderboard
perf = aml.leader.model_performance(valid)
perf.auc()