我有这样的训练数据示例(我有1000部电影用于训练),我需要预测每部电影的“预算”:
film_1 = {
'title': 'The Hobbit: An Unexpected Journey',
'article_size': 25000,
'producer': ['Peter Jackson', 'Fran Walsh', 'Zane Weiner'],
'release_date': some_date(2013, 11, 28),
'running_time': 169,
'country': ['New Zealand', 'UK', 'USA'],
'budget': dec('200000000')
}
'title'
,'producer'
,'country'
等密钥可以被视为机器学习中的功能,而'The Hobbit: An Unexpected Journey'
,25000
等值则可以。,可以被视为用于学习过程的价值观。但是,在训练中,输入主要被接受为实数而不是字符串格式。我是否需要将'title'
,'producer'
,'country'
(字符串的字段)等字段转换为int
(应该进行分类或序列化等)或者一些其他的操作让我能够将这些数据用作我的网络的训练集?
答案 0 :(得分:0)
我想知道这是否是你需要的:
film_list=['title','article_size','producer','release_date','running_time','country','budget']
flist = [(i,j) for i, j in enumerate(film_list)]
label = [ seq[0] for seq in flist ]
name = [ seq[1] for seq in flist ]
print label
print name
>>[0, 1, 2, 3, 4, 5, 6]
['title', 'article_size', 'producer', 'release_date', 'running_time', 'country', 'budget']
或者你可以直接使用你的词典,
labels = film_1.keys()
print labels
# But the keys are sorted, labels[0] will give you 'producer' instead of 'title':
>>['producer', 'title', 'country', 'release_date', 'budget', 'article_size', 'running_time']