<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Load Iris data
Step1:  Concept of Support Vector Machine (SVM)
SVM is a very popular algorithm in machine learning. It is an algorithm based on the intuition. If we have the following two lines to separate the orange squares and blue dots, which one do you think is better?
<img style="border
Step2:  The training results
Step3:  Let's view the performance on the training data, we will plot the confusion matrix. Also, we will plot the decision boundary, which will help us understand more of the capability of the classifier (since we only have two selected features, this makes us eaiser to view the decision boundary).
Step4:  Exercise
Let's do the classification using an Artificial Neural Network (ANN). It is another popular algorithm in machine learning, the structure of a standard ANN is
Step5:  Solution
<ASSISTANT_TASK:>
Python Code:
# import the iris data
iris = datasets.load_iris()
# let's just use two features, so that we can 
# easily visualize them
X = iris.data[:, [0, 2]]
y = iris.target
target_names = iris.target_names
feature_names = iris.feature_names
# get the classes
n_class = len(set(y))
print('We have %d classes in the data'%(n_class))
# let's have a look of the data first
plt.figure(figsize = (10,8))
for i, c, s in (zip(range(n_class), ['b', 'g', 'r'], ['o', '^', '*'])):
    ix = y == i
    plt.scatter(X[:, 0][ix], X[:, 1][ix], color = c, marker = s, s = 60, label = target_names[i])
plt.legend(loc = 2, scatterpoints = 1)
plt.xlabel('Feature 1 - ' + feature_names[0])
plt.ylabel('Feature 2 - ' + feature_names[2])
plt.show()
Explanation: Load Iris data
End of explanation
# Initialize SVM classifier
clf = svm.SVC(kernel='linear')
# Train the classifier with data
clf.fit(X,y)
Explanation: Concept of Support Vector Machine (SVM)
SVM is a very popular algorithm in machine learning. It is an algorithm based on the intuition. If we have the following two lines to separate the orange squares and blue dots, which one do you think is better?
<img style="border:1px solid black;" src="https://raw.githubusercontent.com/qingkaikong/blog/master/43_support_vector_machine_part1/figures/figure_4.jpg" width="600"/> 
<img style="border:1px solid black;" src="https://raw.githubusercontent.com/qingkaikong/blog/master/43_support_vector_machine_part1/figures/figure_5.jpg" width="600"/> 
<img style="border:1px solid black;" src="https://raw.githubusercontent.com/qingkaikong/blog/master/43_support_vector_machine_part1/figures/figure_6.jpg" width="600"/>  
If you want to know more about SVM, check it on Qingkai's blog
Train a SVM
End of explanation
clf.predict(X)
Explanation: The training results
End of explanation
# predict results from the test data
predicted = clf.predict(X)
# plot the confusion matrix
cm = confusion_matrix(y,predicted)
plot_confusion_matrix(cm, classes=iris.target_names,
                      title='Confusion matrix, without normalization')
plot_desicion_boundary(X, y, clf)
Explanation: Let's view the performance on the training data, we will plot the confusion matrix. Also, we will plot the decision boundary, which will help us understand more of the capability of the classifier (since we only have two selected features, this makes us eaiser to view the decision boundary).
End of explanation
from sklearn.neural_network import MLPClassifier
# Initialize ANN classifier
# create an ANN with two hidden layers, each with 10 neurons
hidden_layer_sizes = 
# using a logistic activation function
activation = 
mlp = MLPClassifier(hidden_layer_sizes= hidden_layer_sizes, activation=activation, \
                    max_iter = 2000, random_state=13)
# Train the classifier with the traning data
# predict results from the test data
predicted = 
# plot the confusion matrix
cm = confusion_matrix(y,predicted)
plot_confusion_matrix(cm, classes=iris.target_names,
                      title='Confusion matrix, without normalization')
Explanation: Exercise
Let's do the classification using an Artificial Neural Network (ANN). It is another popular algorithm in machine learning, the structure of a standard ANN is:
<img style="border:1px solid black;" src="https://raw.githubusercontent.com/qingkaikong/20171206_ML_basics_THW/master/images/image_6.png" width="600"/> 
We don't have time to go over the basics of ANN, but you can find more information about it on Qingkai's blog.
End of explanation
%load ../solutions/solution_02.py
Explanation: Solution
End of explanation
<END_TASK>