Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. x_min, x_max = x_train[:, 0].min() - .5, x_train[:, 0].max() + .5
  2. y_min, y_max = x_train[:, 1].min() - .5, x_train[:, 1].max() + .5
  3. h = (x_max / x_min)/100
  4. xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
  5. np.arange(y_min, y_max, h))
  6. plt.subplot(1, 1, 1)
  7. Z = svc.predict(np.c_[xx.ravel(), yy.ravel()])
  8. Z = Z.reshape(xx.shape)
  9. plt.contourf(xx, yy, Z, cmap=plt.cm.Paired, alpha=0.8)
  10. plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Paired)
  11. plt.xlabel('Sepal length')
  12. plt.ylabel('Sepal width')
  13. plt.xlim(xx.min(), xx.max())
  14. plt.title(title)
  15. plt.show()
  16.  
  17. [93.86879233 84.77565909 14.79950721 30.08036637 28.32257801 13.65629103
  18. -1.4152549 -1.06058228 1.08335583]
  19.  
  20. prediction = svm.predict(caracteristicas.reshape(-1,1))[0]
  21.  
  22. #Crear clasificador SVM
  23. svm = SVC(kernel='rbf')
  24. #Entrenar SVM:
  25. svm.fit(x_train.reshape(-1, 1), y_train)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement