我正在try 保存LE编码器的DICT以用于推理,这是训练和应用LE的代码,然后将LE保存到DICT(LABEL_OBJECT)中,然后它将是joblib.ump(Ed)()
for col in data:
if data[col].dtype == 'object':
# If 2 or fewer unique categories
if len(list(data[col].unique())) >= 2:
# Train on the training data
le.fit(data[col])
label_object[col] = le
# Transform both training and testing data
data[col] = le.transform(data[col])
label_object[col] = le
When trying this it seems the classes_ of the LE get overwritten by the last LE, in this case 'day_of_incident'
我不确定是什么导致了这些问题,是代码的逻辑有问题还是我做错了什么?