I would like to use the KNN model of Sklearn.
In order to optimize hyper parameters (k and the distance), I use GridsearchCV from the package.
It works when i just use euclidean, minkowski and chebyshev distances. However when i add mahalanobis and seuclidean distances, the program runs few minutes and then, return this error :
"Buffer has wrong number of dimensions (expected 1, got 2) " and the core crash.
How fix it ?
V=np.cov(X_train3.T)
VI=np.linalg.inv(V)
interval=np.arange(1,30)
paramétres = [
{'n_neighbors':interval , 'metric': ['euclidean', 'minkowski','chebyshev']},
{'n_neighbors': interval, 'metric': ['mahalanobis', 'seuclidean'],'metric_params': [{'V':V },{'VI':VI }]}
]
grid=GridSearchCV(KNeighborsClassifier(),paramétres,cv=10)
grid.fit(X_train3,Y_train3)
print(grid.best_params_)
---------------------------------ERROR------------------------------------------
ValueError Traceback (most recent call last)
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)