예제 #1
0
def input_metrics(targetxml, referencexml):
    rvars = pull_tune_variables(referencexml)
    tvars = pull_tune_variables(targetxml, referencexml)
    rvars.variables.sort(key=lambda x: x.group)
    tvars.variables.sort(key=lambda x: x.group)
    data = {'target': [], 'reference': [], 'min': [], 'max': [], 'key': []}
    for r, t in zip(rvars.variables, tvars.variables):
        if r.group == t.group:
            key = ';'.join([r.idfclass, r.idfobject, r.idffield])
            data['target'].append(float(t.value))
            data['reference'].append(float(r.value))
            data['min'].append(r.minimum)
            data['max'].append(r.maximum)
            data['key'].append(key)
    paes = metrics.pae(data['target'], data['reference'], data['min'], data['max'])
    m = {'pae': {},
         'rmse': {},
         'cvrmse': {},
         'mbe': {},
         'nmbe': {},
         'mape': {}}
    for k, p in zip(data['key'], paes):
        m['pae'][k] = p
    m['rmse']['all inputs'] = metrics.rmse(data['target'], data['reference'])
    m['cvrmse']['all inputs'] = metrics.cvrmse(data['target'], data['reference'])
    m['mbe']['all inputs'] = metrics.mbe(data['target'], data['reference'])
    m['nmbe']['all inputs'] = metrics.nmbe(data['target'], data['reference'])
    m['mape']['all inputs'] = metrics.mape(data['target'], data['reference'])
    return m
예제 #2
0
def input_metrics(targetxml, referencexml):
    rvars = pull_tune_variables(referencexml)
    tvars = pull_tune_variables(targetxml, referencexml)
    rvars.variables.sort(key=lambda x: x.group)
    tvars.variables.sort(key=lambda x: x.group)
    data = {'target': [], 'reference': [], 'min': [], 'max': [], 'key': []}
    for r, t in zip(rvars.variables, tvars.variables):
        if r.group == t.group:
            key = ';'.join([r.idfclass, r.idfobject, r.idffield])
            data['target'].append(float(t.value))
            data['reference'].append(float(r.value))
            data['min'].append(r.minimum)
            data['max'].append(r.maximum)
            data['key'].append(key)
    paes = metrics.pae(data['target'], data['reference'], data['min'],
                       data['max'])
    m = {
        'pae': {},
        'rmse': {},
        'cvrmse': {},
        'mbe': {},
        'nmbe': {},
        'mape': {}
    }
    for k, p in zip(data['key'], paes):
        m['pae'][k] = p
    m['rmse']['all inputs'] = metrics.rmse(data['target'], data['reference'])
    m['cvrmse']['all inputs'] = metrics.cvrmse(data['target'],
                                               data['reference'])
    m['mbe']['all inputs'] = metrics.mbe(data['target'], data['reference'])
    m['nmbe']['all inputs'] = metrics.nmbe(data['target'], data['reference'])
    m['mape']['all inputs'] = metrics.mape(data['target'], data['reference'])
    return m
예제 #3
0
def output_metrics(estresults, actresults):
    m = {'rmse': {}, 'cvrmse': {}, 'mbe': {}, 'nmbe': {}, 'mape': {}}
    estres = column_vectors(estresults)
    actres = column_vectors(actresults)
    for col in actres:
        try:
            m['rmse'][col] = metrics.rmse(estres[col], actres[col])
            m['cvrmse'][col] = metrics.cvrmse(estres[col], actres[col])
            m['mbe'][col] = metrics.mbe(estres[col], actres[col])
            m['nmbe'][col] = metrics.nmbe(estres[col], actres[col])
            m['mape'][col] = metrics.mape(estres[col], actres[col])
        except:
            # If anything crashes it here, just ignore the column in the output.
            pass
    return m
예제 #4
0
def output_metrics(estresults, actresults):
    m = {'rmse': {},
         'cvrmse':{}, 
         'mbe': {},
         'nmbe':{},
         'mape': {}}
    estres = column_vectors(estresults)
    actres = column_vectors(actresults)
    for col in actres:
        try:
            m['rmse'][col] = metrics.rmse(estres[col], actres[col])
            m['cvrmse'][col] = metrics.cvrmse(estres[col], actres[col])
            m['mbe'][col] = metrics.mbe(estres[col], actres[col])
            m['nmbe'][col] = metrics.nmbe(estres[col], actres[col])
            m['mape'][col] = metrics.mape(estres[col], actres[col])
        except:
            # If anything crashes it here, just ignore the column in the output.
            pass
    return m