因此,我使用Python的训练集中的实例计算了两个高基数变量(Postal_Code_L
和Managing_Sales_Office_Nbr
)的证据权重。你知道吗
问题是,现在我想用它们的WOE替换测试集实例中这些高基数变量的值。我该怎么做?你知道吗
更新: I have also made a dataframe, consisting of all unique postal codes in the training set and their WOE。如果邮政编码出现在训练集中,我尝试用下面的代码替换整个数据集中丢失的WOE值,如果邮政编码没有出现在数据集中,则用WOE的平均值替换
对于TestsetwithWOE['posal\u Code\u L']中的i:
if TestsetwithWOE['Postal_Code_L'][i] in WOEvaluespostalcode['MIN_VALUE']:
TestsetwithWOE['Postal_Code_L_WOE'][i] == WOEvaluespostalcode['WOE']
else:
TestsetwithWOE['Postal_Code_L_WOE'][i] == meanWOEPostalCode
运行此代码会导致以下错误: TypeError:无法对类“”进行标签索引3.core.索引.range.RangeIndex范围索引'使用'float'类的索引器[nan]
如果我将两个数据帧的所有列中的所有缺失值都更改为“未知”。我得到KeyError:'未知'。如何更改代码以使其正常工作?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐