data = ['symptom1', 'symptom2', 'symptom3', 22, 74, 'medicine1']
mapping = {
'symptom1':111,
'symptom2':222,
'symptom3':333,
'medicine1':444
}
input_vector = np.array([mapping[x] if type(x) is str else x for x in data])
data = ['symptom1', 'symptom2', 'symptom3', 22, 74, 'medicine1']
#data should be the set() of all your possible string inputs
#you should be able to generate a database just by parsing the input files
mapping = {}
n = 1
for word in data:
for word in data:
if type(word) is str:
if word not in mapping:
mapping[word] = 111*n
n += 1
print(mapping)
{'symptom1': 111, 'symptom2': 222, 'symptom3': 333, 'medicine1': 444}
通常,您会将每个字符串转换为一个数字,并将一个数字数组作为输入。例如,您可以将每个Syntoms和medicine映射为n整数
input_vector
现在是array([111, 222, 333, 22, 74, 444])
,你已经准备好把它输入你的神经网络了您可以使用各种方法自动生成
mapping
dict。 这里有一个:相关问题 更多 >
编程相关推荐