My data train: 3 features (permanent data)
My data test: it changes everytime (2 features or 1 feature), in my example code it's 2 features now.
I want to classify with a different feature, because it's a different dimension. How can I achieve this? Below my code:
def classify(a):
xtrain = np.loadtxt(open("el.csv","rb"), delimiter=",", usecols= (0,1,2), skiprows=1)
print xtrain
>>[[ -56. -82. -110.]
[-110. -110. -110.]
[ -58. -110. -79.]
[ -56. -110. -110.]
[ -57. -83. -110.]
[ -63. -110. -110.]
[-110. -110. -110.]]
ytrain = np.loadtxt(open("el.csv","rb"), delimiter=",", usecols= (3,), dtype=int, skiprows=1)
print ytrain
>>[1 1 2 2 3 3 4]
xtest = np.asarray(a)
xtest = xtest.reshape([1,-1])
print xtest
>>[['-83' '-56']]
knn = neighbors.KNeighborsClassifier(n_neighbors=7, weights='distance') #Fuzzy K-Nearest Neighbor
knn.fit(xtrain, ytrain)
results = knn.predict(xtest)
print results
And the error is:
ValueError: Incompatible dimension for X and Y matrices: X.shape[1] == 2 while Y.shape[1] == 3