This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
code:demo2d [2015/09/28 14:46] asa |
code:demo2d [2016/09/29 14:35] (current) asa |
||
---|---|---|---|
Line 6: | Line 6: | ||
To use it: | To use it: | ||
- | (:source lang=python:) | + | <file python using_demo2d.py> |
import demo2d | import demo2d | ||
Line 17: | Line 17: | ||
demo2d.decision_surface(classifier) | demo2d.decision_surface(classifier) | ||
- | (:sourcend:) | + | </file> |
<file python demo2d.py> | <file python demo2d.py> | ||
Line 61: | Line 60: | ||
if event.key == 'q' : | if event.key == 'q' : | ||
if len(X) == 0 : return | if len(X) == 0 : return | ||
- | print 'done creating data. close this window and use the decisionSurface function' | + | print ('done creating data. close this window and use the decisionSurface function') |
pylab.disconnect(binding_id) | pylab.disconnect(binding_id) | ||
if event.key =='1' or event.key == '2' : | if event.key =='1' or event.key == '2' : | ||
if event.inaxes is not None: | if event.inaxes is not None: | ||
- | print 'data coords', event.xdata, event.ydata | + | print ('data coords', event.xdata, event.ydata) |
X.append([event.xdata, event.ydata]) | X.append([event.xdata, event.ydata]) | ||
Y.append(key_to_class[event.key]) | Y.append(key_to_class[event.key]) |