【发布时间】:2017-11-11 20:30:36
【问题描述】:
我有一个标签名称列表,我枚举并创建了一个字典:
my_list = [b'airplane',
b'automobile',
b'bird',
b'cat',
b'deer',
b'dog',
b'frog',
b'horse',
b'ship',
b'truck']
label_dict =dict(enumerate(my_list))
{0: b'airplane',
1: b'automobile',
2: b'bird',
3: b'cat',
4: b'deer',
5: b'dog',
6: b'frog',
7: b'horse',
8: b'ship',
9: b'truck'}
现在我正在尝试将 map/apply 的 dict 值清理到我的目标中,该目标采用单热编码形式。
y_test[0]
array([ 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.])
y_test[0].map(label_dict) should return:
'cat'
我在玩
(lambda key,value: value for y_test[0] == 1)
但无法提出任何具体的建议
谢谢。
【问题讨论】:
标签: python-3.x numpy machine-learning mapping one-hot-encoding