fork download
  1. # your code goes here
  2. #!/usr/bin/env python
  3. #-*- coding: utf-8 -*-
  4. #7-16.py
  5. import numpy as np
  6. import matplotlib.pyplot as plt
  7. import mlpy
  8. f = np.loadtxt("C:\Users\Administrator\Desktop\data\spiral.data")
  9. x, y = f[:, :2], f[:, 2]
  10. svm = mlpy.LibSvm(svm_type='c_svc', kernel_type='rbf', gamma=100)
  11. svm.learn(x, y)
  12. xmin, xmax = x[:,0].min()-0.1, x[:,0].max()+0.1
  13. ymin, ymax = x[:,1].min()-0.1, x[:,1].max()+0.1
  14. xx, yy = np.meshgrid(np.arange(xmin, xmax, 0.01), np.arange(ymin, ymax, 0.01))
  15. xnew = np.c_[xx.ravel(), yy.ravel()]
  16. ynew = svm.pred(xnew).reshape(xx.shape)
  17. fig = plt.figure(1)
  18. plt.pcolormesh(xx, yy, ynew)
  19. plt.scatter(x[:,0], x[:,1], c=y)
  20. plt.show()
  21.  
  22.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.4/py_compile.py", line 124, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "./prog.py", line 8
    f = np.loadtxt("C:\Users\Administrator\Desktop\data\spiral.data")
                  ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.4/py_compile.py", line 128, in compile
    raise py_exc
py_compile.PyCompileError:   File "./prog.py", line 8
    f = np.loadtxt("C:\Users\Administrator\Desktop\data\spiral.data")
                  ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

stdout
Standard output is empty