July 2019
Beginner to intermediate
298 pages
7h 20m
English
In order to implement a custom hard voting solution, we will use three base learners: a Perceptron (a neural network with a single neuron), a Support Vector Machine (SVM), and a Nearest Neighbor. These are contained in the sklearn.linear_model, sklearn.svm, and sklearn.neighbors packages. Furthermore, we will use the argmax function from NumPy. This function returns the index of an array's (or array-like data structure) element with the highest value. Finally, accuracy_score will calculate the accuracy of each classifier on our test data:
# --- SECTION 1 ---# Import the required librariesfrom sklearn import datasets, linear_model, svm, neighborsfrom sklearn.metrics import accuracy_scorefrom numpy import argmax ...
Read now
Unlock full access