July 2017
Intermediate to advanced
382 pages
9h 13m
English
This is the easy part. Training the MLP classifier is the same as with all other classifiers:
In [11]: mlp.train(X, cv2.ml.ROW_SAMPLE, y)Out[11]: True
The same goes for predicting target labels:
In [12]: _, y_hat = mlp.predict(X)
The easiest way to measure accuracy is by using scikit-learn's helper function:
In [13]: from sklearn.metrics import accuracy_score... accuracy_score(y_hat.round(), y)Out[13]: 0.83999999999999997
It looks like we were able to increase our performance from 81% with a single perceptron to 84% with an MLP consisting of ten hidden-layer neurons and two output neurons. In order to see what changed, we can look at the decision boundary one more time:
In [14]: def plot_decision_boundary(classifier, ...
Read now
Unlock full access