Exemplo n.º 1
0
 def target_4_dataset_save(self,dataset,file):
     compound=dataset.ids.tolist()
     target=dataset.get_task_names()
     print(target)
     w=dataset.w
     print('w.shape')
     print(w.shape)
     compuond_4_target=[]
     target_4=['P21728','P14416','P08908','P28223']
     
     target_4=sorted(target_4,key=lambda x:target.index(x))
     target_4_index=[target.index(i) for i in target_4]
     print('target_4')
     print(target_4_index)
     for i in range(len(compound)):
         z=0
         for j in target_4_index:
         
             if w[i,j]>0:
                 z=z+1
         if z>0:
             compuond_4_target.append(i)
             
         
     compound_shard=[]
     
         
     dataset1=dataset.select(compuond_4_target)
     print(compuond_4_target)
     cpd=compuond_4_target
     metadata_rows=[]
     shard_generator=self.shard_generator(cpd,target_4_index,dataset1)
     for shard_num, (X, y, w, ids) in enumerate(shard_generator):
       basename = "shard-%d" % shard_num
       metadata_rows.append(
           DiskDataset.write_data_to_disk(file, basename,target_4 , X, y, w,
                                          ids))
       metadata_df = DiskDataset._construct_metadata(metadata_rows)
       self.save_metadata(target_4, metadata_df, file)
       time2 = time.time()