Open raj2022 opened 3 years ago
Hello, I am trying to do this code but I am obtaining this error, but do not know where to make changes. Please help me.
npy_data = np.load('back.npy')
Y = npy_data[:,-1]
X = npy_data[:,:-1]
r = np.random.rand(X.shape[0])
Xtrain=X[r>0.5] Xtest=X[r<=0.5] Ytrain=Y[r>0.5] Ytest=Y[r<=0.5]
method_sklearn = SVC(C = 2.0, kernel = 'rbf',tol=0.001,gamma=0.005) method_sklearn.fit(Xtrain,Ytrain)
Hello, I am trying to do this code but I am obtaining this error, but do not know where to make changes. Please help me.
trainin gusing scikit learn
npy_data = np.load('back.npy')
Split numpy array into X (data) and Y (truth)
Y is just last column
Y = npy_data[:,-1]
X is all but last column
X = npy_data[:,:-1]
Random number list for splitting training and testing
r = np.random.rand(X.shape[0])
Get training and testing samples, splitting in half (using 0.5)
Xtrain=X[r>0.5] Xtest=X[r<=0.5] Ytrain=Y[r>0.5] Ytest=Y[r<=0.5]
Create and run the SVC with an rbf kernel
Some tuning has been done to get the gamma and C values.
method_sklearn = SVC(C = 2.0, kernel = 'rbf',tol=0.001,gamma=0.005) method_sklearn.fit(Xtrain,Ytrain)