3)实现代码
from sklearn.preprocessing import MultiLabelBinarizer
mlb = MultiLabelBinarizer()
print(mlb.fit_transform...([(1, 2), (3,)]))
# 输出
array([[1, 1, 0],
[0, 0, 1]])
print(mlb.classes_)
# 输出:array([1, 2, 3]...)
print(mlb.fit_transform([{'sci-fi', 'thriller'}, {'comedy'}]))
# 输出:array([[0, 1, 1],
[1, 0..., 0]])
print(list(mlb.classes_))
# 输出:['comedy', 'sci-fi', 'thriller']
5.平均数编码(Mean Encoding)
1)定义
平均数编码