Question
I ask this qa 4 times,but no true answer yet: Create a set of 2D data ( d=2, features: x=(x_1,x_2) ) 1-Randomly create a set
I ask this qa 4 times,but no true answer yet:
Create a set of 2D data ( d=2, features: x=(x_1,x_2) )
1-Randomly create a set of 20 data points (N=20) such that for each point x=(x_1,x_2), the coordinates x_1,x_2 be integers. x_1,x_2 are to be limited to the [-30,+30] range and uncorrelated.
2-Choose the line x_1+2x_2 - 1.1 = 0 as your target function, where the points on one side of the line map to y=+1
(f=x_1+2x_2-1.5>0) and the other points map to y=-1
(f=x_1+2x_2-1.5<0). Now, you have a set of 20 data points (x,y) as your separable data points.
3-Plot the points on the 2D plane labeling them with + or - or Red and Blue.
5-Implement and run the simple perceptron algorithm. You must write the perceptron code from scratch as opposed to using the code in software packages. Make sure to include declarations next to code lines for ease of readability. How many iterations does it take to arrive at the solution boundary (estimated target function)? Plot 4 iterations including the final one showing the boundary line at each iteration. Draw function f line on the last plot and explain why they are different. Is there any solution that could be better than others?
Also I write this code for this QU but it didnt work,what is the problem?
x_1=[17,-8,-25,8,-19,-27,13,-9,10,-7,8,-29,25,18,15,19,-7,7,5,2];
x_2 =[-1,-15,-3,-16,18,29,-28,2,-25,18,29,-26,26,-29,11,17,2,23,24,8];
a=[17,-8,-25,8,-19,-27,13,-9,10,-7,8,-29,25,18,15,19,-7,7,5,2];
b =[-1,-15,-3,-16,18,29,-28,2,-25,18,29,-26,26,-29,11,17,2,23,24,8];
x_1=-2*x_2+1.1
f = a + 2 * b - 1.5;
plot(x_1,x_2)
hold on
for i = 1:20
if f(i) > 0
scatter(a(i), b(i), 'r');
else if f(i)<0
scatter(a(i), b(i), 'b');
end
end
end
hold on
w = [1, 2, -1.1];
learning_rate = 0.1;
iterations = 10;
while true classified = true;
for i = 1:1000
x = [a(i), b(i), 1];
if sign(dot(w, x)) ~= y(i)
classified = false;
w = w + learning_rate * y(i) * x;
end
end
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started