July 2019
Beginner to intermediate
298 pages
7h 20m
English
Similarly to our custom implementation, we import the required libraries, split our train and test data, and instantiate our base learners. Furthermore, we import scikit-learn's VotingClassifier voting implementation from the sklearn.ensemble package, as follows:
# --- SECTION 1 ---# Import the required librariesfrom sklearn import datasets, linear_model, svm, neighborsfrom sklearn.ensemble import VotingClassifierfrom sklearn.metrics import accuracy_score# Load the datasetbreast_cancer = datasets.load_breast_cancer()x, y = breast_cancer.data, breast_cancer.target# Split the train and test samplestest_samples = 100x_train, y_train = x[:-test_samples], y[:-test_samples]x_test, y_test = x[-test_samples:], y[-test_samples:] ...
Read now
Unlock full access