尝试执行以下代码时出现以下错误。
class LabelOneHotEncoder():
def __init__(self):
self.ohe = OneHotEncoder()
self.le = LabelEncoder()
def fit_transform(self, x):
features = self.le.fit_transform( x)
return self.ohe.fit_transform( features.reshape(-1,1))
def transform( self, x):
return self.ohe.transform( self.le.transform( x.reshape(-1,1)))
def inverse_tranform( self, x):
return self.le.inverse_transform( self.ohe.inverse_tranform( x))
def inverse_labels( self, x):
return self.le.inverse_transform( x)
y = list(map(ImageToLabelDict.get, train_images))
lohe = LabelOneHotEncoder()
y_cat = lohe.fit_transform(y)
错误
perm = ar.argsort(kind='mergesort' if return_index else 'quicksort')
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'
答案 0 :(得分:0)
您的问题非常令人困惑...
缺少很多变量。
我猜可能会在ar
发生。由ar
生成的LabelOneHotEncoder
可能具有一些np.NaN
值。当您将data
放入需要转换为没有某些特征/值的模型时,可能会发生这种情况。
One word: your training data is bigger than the transformed data.