更新时间:2021-12-18 18:08:32
您使用的 check_cv
错误.根据文档:-
You are using check_cv
wrong. According to the documentation:-
check_cv(cv=’warn’, y=None, classifier=False):
cv : int,
cross-validation generator or an iterable, optional
y : array-like, optional
The target variable for supervised learning problems.
classifier : boolean, optional, default False
Whether the task is a classification task,
in which case stratified KFold will be used
所以它需要 y
和 estimator
输入.但是您提供的 X
和 y
是错误的.更改以下几行:
So it wants y
and estimator
in input. But you are providing X
and y
which is wrong. Change the below lines:
cv = check_cv(self.cv, X, y)
knn = KNeighborsClassifier(metric='precomputed', algorithm='brute')
到:
knn = KNeighborsClassifier(metric='precomputed', algorithm='brute')
cv = check_cv(self.cv, y, knn)
注意行的顺序.