eval.py
def grid(model, x, y, cvals, t1vals, t2vals, k=3):
  """
  Performs grid search for hyperparameters used in the uniformOVA model.
  
  NB: This was re-implemented (vs. using grid search from sklearn) because
  sklearn grid search would try every (C, t1, t2) tuple, which would retrain
  the SVC with the same C value t1 x t2 times. This trains the SVC once, 
  and then searches over the (t1, t2) 2-tuples, which is a fast thresholding
  operation.
  
  Params:
    model - a model that has parameter C, t1 and t2
    x - training features
    y - training labels
    cvals - list or array of C parameter values for linear SVC
    t1vals - list or array of t1 (global threshold) values
    t2vals - list or array of t2 (proximity to max dv threshold) values
    k - # of cross-validation folds
    
  Returns:
    an array with every tuple of C, t1 and t2, along with its mean F1-score
  """
  result = []
  for c in cvals:
    model.c = c
    (pred, dv) = predictCV(model, x, y, k)
    for t1val in t1vals:
      for t2val in t2vals:
        pred = models.repredict(dv, t1val, t2val)
        score = f1_score(y, pred, average='samples')
        result.append((c, t1val, t2val, score))
  return result

  Performs grid search for hyperparameters used in the uniformOVA model.
  
  NB: This was re-implemented (vs. using grid search from sklearn) because
  sklearn grid search would try every (C, t1, t2) tuple, which would retrain
  the SVC with the same C value t1 x t2 times. This trains the SVC once, 
  and then searches over the (t1, t2) 2-tuples, which is a fast thresholding
  operation.
  
  Params:
    model - a model that has parameter C, t1 and t2
    x - training features
    y - training labels
    cvals - list or array of C parameter values for linear SVC
    t1vals - list or array of t1 (global threshold) values
    t2vals - list or array of t2 (proximity to max dv threshold) values
    k - # of cross-validation folds
    
  Returns:
    an array with every tuple of C, t1 and t2, along with its mean F1-score
  
Performs grid search for hyperparameters used in the uniformOVA model.
NB: This was re-implemented (vs. using grid search from sklearn) because
sklearn grid search would try every (C, t1, t2) tuple, which would retrain
the SVC with the same C value t1 x t2 times. This trains the SVC once,
and then searches over the (t1, t2) 2-tuples, which is a fast thresholding
operation.



an array with every tuple of C, t1 and t2, along with its mean F1-score
Performs grid search for hyperparameters used in the uniformOVA model . NB : This was re - implemented ( vs . using grid search from sklearn ) because sklearn grid search would try every ( C t1 t2 ) tuple which would retrain the SVC with the same C value t1 x t2 times . This trains the SVC once and then searches over the ( t1 t2 ) 2 - tuples which is a fast thresholding operation . an array with every tuple of C t1 and t2 along with its mean F1 - score
def grid(model, x, y, cvals, t1vals, t2vals, k=3):
  result = []
  for c in cvals:
    model.c = c
    (pred, dv) = predictCV(model, x, y, k)
    for t1val in t1vals:
      for t2val in t2vals:
        pred = models.repredict(dv, t1val, t2val)
        score = f1_score(y, pred, average='samples')
        result.append((c, t1val, t2val, score))
  return result
def grid ( model , x , y , cvals , t1vals , t2vals , k = 3 ) : result = [ ] for c in cvals : model . c = c ( pred , dv ) = predictCV ( model , x , y , k ) for t1val in t1vals : for t2val in t2vals : pred = models . repredict ( dv , t1val , t2val ) score = f1_score ( y , pred , average = 'samples' ) result . append ( ( c , t1val , t2val , score ) ) return result
Performs grid search for hyperparameters used in the uniformOVA model.
Performs grid search for hyperparameters used in the uniformOVA model .
"""
  Performs grid search for hyperparameters used in the uniformOVA model.
  
  NB: This was re-implemented (vs. using grid search from sklearn) because
  sklearn grid search would try every (C, t1, t2) tuple, which would retrain
  the SVC with the same C value t1 x t2 times. This trains the SVC once, 
  and then searches over the (t1, t2) 2-tuples, which is a fast thresholding
  operation.
  
  Params:
    model - a model that has parameter C, t1 and t2
    x - training features
    y - training labels
    cvals - list or array of C parameter values for linear SVC
    t1vals - list or array of t1 (global threshold) values
    t2vals - list or array of t2 (proximity to max dv threshold) values
    k - # of cross-validation folds
    
  Returns:
    an array with every tuple of C, t1 and t2, along with its mean F1-score
  """
model
x
y
cvals
t1vals
t2vals
k