My last two posts have been talking creating linearly separable data. Hopefully you found some of the features interesting – for example, the idea of creating interactivity using grab handles. But I never really gave a purpose to what I was doing: I wanted to write some machine learning code – specifically a perceptron learning algorithm – and to test the code I needed to create some data on which it could act.
I am close to that goal.
Based on the code from the previous post I have the following functionality:
My final task is to link the movements of the grab handles back to the colour of the data points, which is a property of the values of the response column. That requires modification to the event handlers associated with the grab handles.
The code modifications have been highlighted:
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
Do Drag = Function({x,y}, oldY = pcy; pcy = y; delta = pcy - oldY; p1y = p1y + delta; p2y = p2y + delta; yLine = Matrix({p1y,p2y}); dt = Current Data Table(); cValue = dt << Get Table Variable("c"); c = Num(cValue); newC = c + delta; dt << Set Table Variable("c",newC); ); Do Twist = Function({pos,x,y}, If (pos==1, oldY = p1y; p1y = y; delta = p1y - oldY; p2y = p2y - delta; , oldY = p2Y; p2y = y; delta = p2y - oldY; p1y = p1y - delta; ); yLine = Matrix({p1y,p2y}); dt = Current Data Table(); mValue = dt << Get Table Variable("m"); m = Num(mValue); newM = p2y - p1y; dt << Set Table Variable("m",newM); cValue = dt << Get Table Variable("c"); c = Num(cValue); newC = c - delta; dt << Set Table Variable("c",newC); ); |
With these modifications the interactions on the graph feed back into the formula definition for my binary response:
Now that I can create an arbitrary pattern of separable data, I can apply a machine learning algorithm that seeks to identify the boundary separating the two classes of response. That’s the next post.
De eerste uiting, dat zich van die nieuw bevrijden vernemen liet, was een doordringend hoerageschreeuw, hetw