Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if x1 < x2 then
- class1
- else
- class2
- import numpy as np
- from sklearn.svm import SVC
- # Generate 1000 samples with 2 features with random values
- X_train = np.random.rand(1000,2)
- # Label each sample. If feature "x1" is less than feature "x2" then label as 1, otherwise label is 0.
- y_train = X_train[:,0] < X_train[:,1]
- y_train = y_train.astype(int) # convert boolean to 0 and 1
- svc = SVC(kernel = "rbf", C = 0.9) # tried all kernels and C values from 0.1 to 1.0
- svc.fit(X_train, y_train)
- print("SVC score: %f" % svc.score(X_train, y_train))
- SVC score: 0.992000
Add Comment
Please, Sign In to add comment