(self,reference_set_dict, monotone_relationship, minval, maxval)
Initialize a scoring function. Called through create() above.
Initialize a scoring function. Called through create() above.
Initialize a scoring function . Called through create () above .
def __init__(self,reference_set_dict, monotone_relationship, minval, maxval):
    """ Initialize a scoring function. Called through create() above. """
    np_input = np.array(list(reference_set_dict.keys()), dtype=float)
    self.monorel = np.array(monotone_relationship)
    if not np.sum(np.absolute(self.monorel)) == len(monotone_relationship):
      raise ScoreCreationError("Entries in monotone_relationship vector must be 1 or -1 exclusively.")
    # Scale all values to fall in unit length
    self.scale = self.monorel*(np.clip(np.amax(np_input, axis=0)-np.amin(np_input, axis=0),.001,1000))
    # Create new structure to hold the scaled reference set
    self.points = {}
    for (p,v) in reference_set_dict.items():
      key = np.array(p)/self.scale
      self.points[tuple(key.tolist())]=v
    # minval/maxval intelligent handling
    if minval is not None:
      self.minval = float(minval)
    else:
      self.minval = None
    if maxval is not None:
      self.maxval = float(maxval)
    else:
      self.maxval = None
    self.__check_monotonicity__()
    if not (minval is None and maxval is None):
      self.__check_bounds__()

    self.dim = len(monotone_relationship)
    # Solve the optimization
    plus_vals, minus_vals = self.__solve__()
    # point_objs holds the cones emanating from each point
    self.point_objs = []
    for ((p,v),plusv,minusv) in zip(self.points.items(), plus_vals, minus_vals):
      sp,ip = zip(*plusv)
      sm,im = zip(*minusv)
      self.point_objs.append(Point(p,v,sp,sm,ip,im))
def __init__ ( self , reference_set_dict , monotone_relationship , minval , maxval ) : np_input = np . array ( list ( reference_set_dict . keys ( ) ) , dtype = float ) self . monorel = np . array ( monotone_relationship ) if not np . sum ( np . absolute ( self . monorel ) ) == len ( monotone_relationship ) : raise ScoreCreationError ( "Entries in monotone_relationship vector must be 1 or -1 exclusively." ) # Scale all values to fall in unit length self . scale = self . monorel * ( np . clip ( np . amax ( np_input , axis = 0 ) - np . amin ( np_input , axis = 0 ) , .001 , 1000 ) ) # Create new structure to hold the scaled reference set self . points = { } for ( p , v ) in reference_set_dict . items ( ) : key = np . array ( p ) / self . scale self . points [ tuple ( key . tolist ( ) ) ] = v # minval/maxval intelligent handling if minval is not None : self . minval = float ( minval ) else : self . minval = None if maxval is not None : self . maxval = float ( maxval ) else : self . maxval = None self . __check_monotonicity__ ( ) if not ( minval is None and maxval is None ) : self . __check_bounds__ ( ) self . dim = len ( monotone_relationship ) # Solve the optimization plus_vals , minus_vals = self . __solve__ ( ) # point_objs holds the cones emanating from each point self . point_objs = [ ] for ( ( p , v ) , plusv , minusv ) in zip ( self . points . items ( ) , plus_vals , minus_vals ) : sp , ip = zip ( * plusv ) sm , im = zip ( * minusv ) self . point_objs . append ( Point ( p , v , sp , sm , ip , im ) )