我在实现模糊knn https://github.com/sahilsehwag/FuzzyKNN时遇到麻烦,当我运行k最近邻居时,它可以工作但不模糊
def fit(self, X, y=None):
self._check_params(X,y)
self.X = X
self.y = y
self.xdim = len(self.X[0]) #in here
self.n = len(y)
classes = list(set(y))
classes.sort()
self.classes = classes
self.df = pd.DataFrame(self.X)
self.df['y'] = self.y
self.memberships = self._compute_memberships()
self.df['membership'] = self.memberships
self.fitted_ = True
return self
我跑步时出现错误
File "C: /Users/DELL/.spyder-py3/temp.py", line 172, in <module>
custModel.fit (xTrain, yTrain)
File "C: /Users/DELL/.spyder-py3/temp.py", line 53, in fit
self.xdim = len (self.X [0])
KeyError: 0