【发布时间】:2022-08-12 16:58:09
【问题描述】:
我试图保存 LE 编码器的 dict 以用于推理,这是训练和应用 LE 的代码,然后将 LE 保存到 dict (label_object) 中,然后将是 joblib.dump(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
尝试此操作时,LE 的 classes_ 似乎被最后一个 LE 覆盖,在本例中为 \'day_of_incident\'
我不确定是什么导致了这个问题,是代码逻辑有问题还是我做错了什么?
标签: python scikit-learn data-science