-->

Saturday, April 20, 2013

dealing with matrices "a la matlab"


Given a list :

your_list=[]

you play with your list :

your_list.append(3)

Most important thing is to handle it as a numpy array:

your_array_np = np.array(your_array,'dtype=int8')

and then you can do fancy things like indexing it using vectors of indexes, exactly as matlab:


gt=[]                                                                             
                                                                                  
c_idx=1                                                                           
for l in labl:                                                                    
    if (len(re.findall(classtxt[c_idx],l))>0):                                    
        gt.append(1)                                                              
    else:                                                                         
        gt.append(0)                                                              
                     

gta=np.array(gt,dtype='int8')

len(find(gta[find((gta[:]-int8(sgdMat[:,c_idx]>th))==0)]!=0))

No comments:

Post a Comment