#1




PLA: Let share nice visualizations
Hi!
I think all of us plotted different pictures. Some of them are very nice. For example I get this for PLA learning on N=20. What nice visualisations do you have? 
#2




Re: PLA: Let share nice visualizations
I don't think it's sharing answers to homework if we exchange code for plotting. Am new to Octave and not having the best luck getting nicelooking plots so far. Would be thrilled to get just the snippet of code people use for visualizing different solutions.

#3




Re: PLA: Let share nice visualizations
I'm just going to paste the Octave code right here. Hope that's OK.
This is code to display the current state of the perceptron, displaying the true separating line, the current hypothesis and all the points. Wrongly classified points are big; rightly classified points are little. Optionally, you can specify the new hypothesis and the currently selected misclassified point, and then they too will be displayed. When I call this function, I put a pause statement afterwards, so I can step through the algorithm watching it move the hypothesis line and reclassify all the points. For some reason I'm getting a divide by zero warning for the statements with && in them. I ignore it. Code:
function draw_percept(points,hypothesis, predictions, true_line, target, bad, new_h) # points (number of points, weights) is the data points. the bias weight is LAST # hypothesis is the hypothesis. bias term is LAST. # predictions(1, N) is what the hypothesis predicts for the points. # true_line is the true separating line. bias term is LAST # target is the correct classifications for the points # bad is optional; it's the misclassified point # new_h is optional; it's the new hypothesis [hypx hypy] = pts_from_hypothesis(hypothesis); [truex truey] = pts_from_hypothesis(true_line); rightly_on = find(predictions == target & predictions == 1); wrongly_on = find(predictions != target & predictions ==1); rightly_off = find(predictions == target & predictions == 1); wrongly_off = find(predictions!= target & predictions == 1); hold off; # if we are displaying old & new hypotheses, # display true line, old hypothesis, new hypothesis if nargin >6 [newx newy] = pts_from_hypothesis(new_h); plot(hypx, hypy, 'r', truex, truey,'g',newx, newy,':b'); legend("old hypothesis red", "true line green", "new hypothesis blue", "location", "southeast"); else # otherwise plot the hypothesis & real line plot(hypx, hypy, 'r', truex, truey,'g'); legend("old hypothesis", "new hypothesis", "location", "southeast"); end axis([1 1 1 1]); hold on; title("Perceptron"); # plot the points scatter(points(rightly_on, 1),points(rightly_on, 2), 'g'); hold on; scatter(points(rightly_off, 1),points(rightly_off, 2), 'b'); hold on; scatter(points(wrongly_on, 1),points(wrongly_on, 2),15, 'r'); hold on; scatter(points(wrongly_off, 1),points(wrongly_off, 2),15, 'c'); # if we're displaying the selected bad point, display it if nargin >3 hold on; scatter(bad(1), bad(2), 20, 'b'); end end function [xs ys] = pts_from_hypothesis(hypothesis) # hypothesis is a, b, c where line is ax + by + c> 0 # so y = (a/b)x  c/b # and x =(b/a)y  c/a # we need to find the the intercepts for y=1, x=1, y=1 and # x = 1. Two of those points will be in the [1,1],[1,1] box a = hypothesis(1); b = hypothesis(2); c= hypothesis(3); xm1int = (bc)/a; ym1int = (ac)/b; x1int = (bc)/a; y1int = (ac)/b; xs = [1 1 xm1int x1int]; ys = [ym1int y1int 1 1]; end 
#4




Re: PLA: Let share nice visualizations
Wow, nice figure. I didn't visualize it like that. I chose to make an animation of the process

#5




Re: PLA: Let share nice visualizations
Please, good sir, do share it

#6




Re: PLA: Let share nice visualizations
Here is a visualization of the algorithm with n=50 points. The point in the circle is the chosen misclassified point in the current iteration. The final yellow line is the selected hypothesis.

#7




Re: PLA: Let share nice visualizations
__________________
Where everyone thinks alike, no one thinks very much 
#8




Re: PLA: Let share nice visualizations
I never did any plots.
I did a few drawings with a few points on them to understand the geometry, and once I understood that, believed in the equations. But sometimes plots are nice to see what it is really doing. 
#9




Re: PLA: Let share nice visualizations
Thanks Anne for sharing your code. Helped me pick up a few things that I was able to use to produce my own plots.

#10




Re: PLA: Let share nice visualizations

Thread Tools  
Display Modes  

