evalMetricsWithTimeseries?


#1

Is there a way to use the results of evalMetrics as inputs to other evalMetrics calls, similar to evalMetricsWithMetadata?


How to speed up evaluation of complex metrics
#2

you can use bindings and pass the time series in the EvalMetricsSpec


#3

Here’s a concrete example:


var ts1 = Timeseries.makeNorm(NormTimeseriesDoubleSpec.make({
    start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-5),
    end: DateTime.nowWithoutZone().toDateMidnight(),
    interval: 'DAY',
    data: [1, 2, 3, 4, 5]
}));

var ts2 = Facility.evalMetricsWithMetadata({
    ids: ['0001'],
    expressions: ['TestMetric'],
    start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-5),
    end: DateTime.nowWithoutZone().toDateMidnight(),
	interval: 'DAY',
    bindings: {
        'ActualRevenue': ts1
    }
}, [
	CompoundMetric.make({
        id: 'TestMetric',
        name: 'TestMetric',
        expression: 'ActualRevenue + 1'
    })
    ]
)

// will be [2, 3, 4, 5, 6]
c3Viz(ts2)

#4

Thanks. So, it seems I can use a timeseries in a binding without having to declare variables. Like, a binding takes precedence.
Ideally, that is my use case: evaluating a metric as-is, then by replacing a piece of its expression by an already evaluated metric to plug into the evaluation (i.e. not to re-evaluate).


#5

Yep. I’m not sure if this is exclusive to Timeseries values being passed in or if you can use bindings to set the value of anything within a metric without declaring variables on that metric.

I suspect this can only be done for Timeseries bindings because I believe this became supported in the interest of making Compound metric tests much much easier to write