什么是onehot编码,python one-hot编码

  什么是onehot编码,python one-hot编码

  将生物序列转换为onehot代码以读取文件,请注意,该文件没有序列相似性搜索工具文件的描述行,只有序列行。另存为csv,然后单击,每行包含一个字符的frompmpiportarrayfromnmpiportargmaxfromskneel。preprocessingimportlabelencoderfromskneel。预处理导入或numpyasNPflag=0#请注意,正采样为1,负采样为0。这是在数据中添加类别defprocess _ one _ hot(input _ word):input _ word=list)input _ word)# print(input _ word)就是加上打印one hot _ encoder=onehotencoder(sparse=false)integer _ encoded=NP .数组)input_word).重塑rray(输入字).整形(len ) input_word),1)打印(integer _ encoded)one hot _ encoded=one hot _ encoded特征提取完成。 #这里的问题是,首先要保存特征吗?#保存时通过添加y标记de fread _ seq _ save _ one hot(read _ file)save _ file(:# result _ list=list)result _ str r )ASF:for line INF。re end n )#删除列表中每个元素的换行符#result_list.append(line),并将序列转换为#打印(结果列表)样品# print(result _ str)one hot _ encoded=process _ one _ hot)result _ str(save=PD。数据帧)一个热帧)g)新列打印)保存)save.to_CSV)添加保存索引=假,标题=假为行索引和列标题# onehot特征提取# 意味着不保存ei _ false _ test。txt ei _ false _ train。txt ei _ true _ test。txt ei _ true _ true

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: