...
Here is an example of a Simple Metric:
Code Block | ||
---|---|---|
| ||
met = c3.SimpleMetric( id='JHU_ConfirmedCases2_OutbreakLocation', name='JHU_ConfirmedCases2', srcType='OutbreakLocation', path="aggregateMeasurements.(measurementType == 'confirmed' && origin == " "'Johns Hopkins University')", tsDeclexpression='interpolate(avg(avg(normalized.data.value)), "PREVIOUS", "MISSING")' ) |
...
Another type of SimpleMetric is a tsDecl (Timeseries Declaration) metric. tsDecl metrics are often used to turn non-timeseries raw data (e.g., event data, status data, or data with irregular intervals) into timeseries. tsDecl metrics have the same fields as standard SimpleMetric, except for the 'tsDecl' field, which replaces the 'expression' field. tsDecl metrics may allow users the added flexibility to define new metrics which the expression field may not support. Using a tsDecl metric, the above metric can be re-written as:
Code Block |
---|
sample_met = c3.SimpleMetric({ 'id': 'SampleMetric_SampleType='JHU_ConfirmedCases3_OutbreakLocation', 'name=': 'SampleMetric'JHU_ConfirmedCases3', 'srcType=': OutbreakLocation'SampleType', 'path': 'timeseriesValues', 'tsDecl': path="aggregateMeasurements.(measurementType == 'confirmed' && origin == " "'Johns Hopkins University')", tsDecl={ 'data': 'data', 'treatment': 'AVERAGEAVG', 'start': 'start', 'value': 'value' } }) |
Please note that the above examples do not have an example context in which they work. This will be updated soon with a version backed up by a working exercise.
...
An example CompoundMetric is:
Code Block | ||
---|---|---|
| ||
sample_compound_met = c3.CompoundMetric({ 'id=': 'CompoundMetric'JHU_CaseFatalityRate', 'name': 'CompoundMetric='JHU_CaseFatalityRate', 'expression': 'window("AVG", SimpleMetric, 0, 7)', }='JHU_ConfirmedDeaths/JHU_ConfirmedCases', ) |
Please note, the above example is not tied to any sample exercises or hands-on tutorials. Sample exercises and hands-on tutorials will be added to this Wiki shortly.
...
Python:
Code Block | ||
---|---|---|
| ||
import pandas as pd
pd.DataFrame(c3.OutbreakLocation.listMetrics().toJson()) |
...