字符种类转换one hotlabel

发布时间 2023-11-28 14:40:29作者: ZephyrYin
from sklearn.preprocessing import LabelEncoder

cell_name_label=pd_data['cell_type']
conpound_name_label=pd_data['sm_lincs_id']
cell_cat=LabelEncoder().fit_transform(cell_name_label)
cell_label=F.one_hot(torch.from_numpy(cell_cat).long())#,max(cell_cat)
conpound_cat=LabelEncoder().fit_transform(conpound_name_label)
conpound_label=F.one_hot(torch.from_numpy(conpound_cat).long())