Example #1
0
    prefered_vect =  array([ int(x) for x in bytearray.fromhex(prefered_color)[0::1] ] )
    max_size = norm( prefered_vect ) * norm( rgb_vect ) 
    return  max_size > 0  and  ( 
                1.0 * sum( prefered_vect * rgb_vect)  / ( max_size )
            ) or -1


criterion_ponderation = VectorDict(float, dict( 
    eye = 1 ,
    fitness = 5,
    bankable = 4,
    extra = .5,
    not_too_expensive = .1
) )

norm_of_choice = criterion_ponderation.dot(criterion_ponderation)


for candidate,ldot in    map ( 
            lambda x :  [ 
                VectorDict(VectorDict,x) , criterion_ponderation.dot( 
                    criterion_ponderation * matrix( x ) 
                )
            ] , 
            data
        ) : 
    if ldot > .5:
         candidate.pprint()
         print "fitting with a projection of %f" % ldot

criterion_ponderation = VectorDict(float, dict(