text_plain_output_1.png
"""
from sklearn.svm import SVC, LinearSVC
from sklearn.ensemble import RandomForestClassifier , GradientBoostingClassifier, AdaBoostClassifier, VotingClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import KNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
model_list = {
    "random_forest": RandomForestClassifier(n_estimators=100, max_depth=10,min_samples_split=2),
    "SVC": SVC(),
    "GBDT": GradientBoostingClassifier(n_estimators=10, learning_rate=0.3, max_depth=4, random_state=0),
    "KNN": KNeighborsClassifier(n_neighbors = 3),
    "GaussianNB": GaussianNB(),
    "LR": LogisticRegression()
}.items()
weight = []
for (name, model) in model_list:
    model.fit(train_X, train_y)
    train_score = model.score( train_X , train_y )
    valid_score = model.score( valid_X , valid_y )
    weight.append(valid_score)
    print ("%s, train_score:%f, valid_score:%f" % (name, train_score , valid_score) )
# voting ensemble
eclf = VotingClassifier(estimators=model_list, weights=weight)
eclf.fit(train_X, train_y)
print (eclf.score(train_X, train_y))
print (eclf.score(valid_X, valid_y))
test_Y = [int(x) for x in eclf.predict(test_X)]
print (len(test_Y))
"""