不指定近邻个数的近邻分类器
import numpy as np
from sklearn import datasets
import pandas as pd
from sklearn.metrics.pairwise import rbf_kernel
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import accuracy_score
from sklearn.neighbors import KNeighborsClassifier
class PWC():
def __init__(self,train_X,train_y,kerel = "rbf"):
self.kernel = kerel
self.X = train_X
self.y = train_y
self.labels = np.sort(np.unique(self.y))
self.test_X = None
self.K = None
def fit(self,X,y):
self.X = X
self.y = y
def pred(self,test_X):
self.test_X = te