neuroscout/populate/utils.py
def compute_pred_stats(session, pred, commit=False):
    """ Computes hard coded pre-computed metrics upon ingestion (or on demand)
    for a Predictor """
    def get_max(vals):
        if vals:
            vals =  max(vals)
        return vals

    def get_min(vals):
        if vals:
            vals =  min(vals)
        return vals
    
    def remove_nas(vals):
        return [v for v in vals if v == 'n/a']

    def num_na(vals):
        if vals:
            vals = len(remove_nas(vals))
        return vals
    
    def mean(vals):
        if vals:
            vals = np.mean(vals)
        return vals
    
    values = pred.float_values
    
    pred.max = get_max(values)
    pred.min = get_min(values)
    pred.num_na = num_na(values)
    pred.mean = mean(values)
        
    if commit:
        session.add(pred)
        session.commit()
        
    return pred
 Computes hard coded pre-computed metrics upon ingestion (or on demand)
    for a Predictor 
Computes hard coded pre-computed metrics upon ingestion (or on demand)
for a Predictor
Computes hard coded pre - computed metrics upon ingestion ( or on demand ) for a Predictor
def compute_pred_stats(session, pred, commit=False):
    def get_max(vals):
        if vals:
            vals =  max(vals)
        return vals
    def get_min(vals):
        if vals:
            vals =  min(vals)
        return vals
    def remove_nas(vals):
        return [v for v in vals if v == 'n/a']
    def num_na(vals):
        if vals:
            vals = len(remove_nas(vals))
        return vals
    def mean(vals):
        if vals:
            vals = np.mean(vals)
        return vals
    values = pred.float_values
    pred.max = get_max(values)
    pred.min = get_min(values)
    pred.num_na = num_na(values)
    pred.mean = mean(values)
    if commit:
        session.add(pred)
        session.commit()
    return pred
def compute_pred_stats ( session , pred , commit = False ) : def get_max ( vals ) : if vals : vals = max ( vals ) return vals def get_min ( vals ) : if vals : vals = min ( vals ) return vals def remove_nas ( vals ) : return [ v for v in vals if v == 'n/a' ] def num_na ( vals ) : if vals : vals = len ( remove_nas ( vals ) ) return vals def mean ( vals ) : if vals : vals = np . mean ( vals ) return vals values = pred . float_values pred . max = get_max ( values ) pred . min = get_min ( values ) pred . num_na = num_na ( values ) pred . mean = mean ( values ) if commit : session . add ( pred ) session . commit ( ) return pred
Computes hard coded pre-computed metrics upon ingestion (or on demand)
for a Predictor
Computes hard coded pre - computed metrics upon ingestion ( or on demand ) for a Predictor
""" Computes hard coded pre-computed metrics upon ingestion (or on demand)
    for a Predictor """
session
pred
commit