Guest User

Untitled

a guest
Jul 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. if x1 < x2 then
  2. class1
  3. else
  4. class2
  5.  
  6. import numpy as np
  7. from sklearn.svm import SVC
  8.  
  9. # Generate 1000 samples with 2 features with random values
  10. X_train = np.random.rand(1000,2)
  11.  
  12. # Label each sample. If feature "x1" is less than feature "x2" then label as 1, otherwise label is 0.
  13. y_train = X_train[:,0] < X_train[:,1]
  14. y_train = y_train.astype(int) # convert boolean to 0 and 1
  15.  
  16. svc = SVC(kernel = "rbf", C = 0.9) # tried all kernels and C values from 0.1 to 1.0
  17.  
  18. svc.fit(X_train, y_train)
  19. print("SVC score: %f" % svc.score(X_train, y_train))
  20.  
  21. SVC score: 0.992000
Add Comment
Please, Sign In to add comment