$20
Demo:
Analyze the given program PerceptronExample, which consists of following parts:
Prepare mydata by generating 2 dimensional linearly separable data.
mydata = rand(500,2);
% Separate the data into two classes acceptindex = abs(mydata(:,1)-mydata(:,2))>0.012; mydata = mydata(acceptindex,:); % data myclasses = mydata(:,1)>mydata(:,2); % labels
[m n]=size(mydata);
You may check the data distribution using:
scatter(mydata(:,1),mydata(:,2))
Train the perceptron by calling the function PerceptronTrn with the prepared training data (x, y), which will return the connection weights, the bias, and the number of iteration;
Test the trained Perceptron model with the testing data (xt, yt), by calling another function PerceptronTst, which will return the testing error;
Display the two classes of data points with a separating line.
Exercise:
The Perceptron training function uses a learning rate 0.5 and a threshold 0.5. Change these two parameters, e.g. learning rate 0.1 and threshold 0, and observe the differences;
Revise the program to calculate the Root-Mean-Square (RMS) error for every input data points and display the error curve, i.e. RMS vs. iteration.