<jupyter_start><jupyter_text>Voting Classifier aggregate the predictions of each classifier.  predict the class with majority votes- hard voting classifier<jupyter_code>import pandas as pd
from sklearn import model_selection
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
from sklearn.ensemble import VotingClassifier
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data"
names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
dataframe = pd.read_csv(url, names=names)
array = dataframe.values
X = array[:,0:8]
Y = array[:,8]
Y #binary response variable
seed = 9
kfold = model_selection.KFold(n_splits=10, random_state=seed)
# create the sub models
estimators = []
model1 = LogisticRegression()
estimators.append(('logistic', model1))
model2 = DecisionTreeClassifier()
estimators.append(('cart', model2))
model3 = SVC()
estimators.append(('svm', model3))
# create the ensemble model
ensemble = VotingClassifier(estimators)
results = model_selection.cross_val_score(ensemble, X, Y, cv=kfold)
print(results.mean()) #mean estimate of classification accuracy.<jupyter_output>0.732980177717
{'fraction_non_alphanumeric': 0.11811652035115722, 'fraction_numerical': 0.019952114924181964, 'mean_word_length': 7.142857142857143, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '146202', 'license': 'MIT', 'n_tokens_mistral': 424, 'n_tokens_neox': 409, 'n_words': 104, 'path': 'section7/.ipynb_checkpoints/Section11_Lecture106-checkpoint.ipynb', 'repo_name': 'PacktPublishing/Regression-Modeling-With-Statistics-and-Machine-Learning-in-Python', 'size': '1253'}