...
To declare a compound metric, users should specify the following fields:
- 'id': compoun
An example CompoundMetric is:
Code Block | ||
---|---|---|
| ||
sample_compound_met = c3.CompoundMetric.make({
'id': 'CompoundMetric',
'name': 'CompoundMetric',
'expression': 'window("AVG", SimpleMetric, 0, 7)',
}) |
Please note that the above example does not have an example context in which it will work. This will be updated soon with a version backed up by a working exercise.
For more detail, see the C3 documentation on CompoundMetrics here: https://developer.c3.ai/docs/7.12.0/guide/guide-c3aisuite-basic/metrics-compound-metrics
Evaluating Metrics
Types on which you can evaluate a metric mixin the Type 'MetricEvaluatable' (C3 Docs here: https://developer.c3.ai/docs/7.12.0/type/MetricEvaluatable)
Finding Metrics
Not all SimpleMetrics are defined on all types.
This bestows the function 'listMetrics' (among others) to that type, so if you're unsure what kind of metrics are available for a given type, execute that function to get a list, for example:
Javascript:
Code Block | ||
---|---|---|
| ||
var metrics = SmartBulb.listMetrics()
c3Grid(metrics) |
Python:
Code Block | ||
---|---|---|
| ||
pd.DataFrame(c3.SmartBulb.listMetrics().toJson()) |
- compound metric's unique id, typically the same as 'name' (e.g., BLS_UnemploymentRate)
- 'name': compound metric's name (e.g., BLS_UnemploymentRate)
- description: compound metric's description (optional field)
- expression: the expression (or ExpressionEngineFunction) applied to the metrics underlying the Compound metric (e.g., "BLS_LaborForcePopulation ? 100 * BLS_UnemployedPopulation / BLS_LaborForcePopulation: null")
An example CompoundMetric is:
Code Block | ||
---|---|---|
| ||
sample_compound_met = c3.CompoundMetric({
'id': 'CompoundMetric',
'name': 'CompoundMetric',
'expression': 'window("AVG", SimpleMetric, 0, 7)',
}) |
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.
To learn more about Compound metrics, please see the C3.ai Developer Documentation here:
- https://developer.c3.ai/docs/7.12.17/topic/metrics-compound-metrics
- https://developer.c3.ai/docs/7.12.17/topic/tutorial-compound-metrics
Finding, Evaluating, and Visualizing Metrics
Users can evaluate & visualize metrics built in the C3 AI Suite, via the JavaScript console or a hosted Jupyter notebook.
Finding Metrics
All metrics that users build and deploy in the C3 AI Suite are also stored in C3.ai Types. To view a list of all the simple and compound metrics applicable to a C3.ai Type, run the 'listMetrics' method, as shown below:
Javascript:
Code Block | ||
---|---|---|
| ||
var metrics = SmartBulb.listMetrics()
c3Grid(metrics) |
Python:
Code Block | ||
---|---|---|
| ||
pd.DataFrame(c3.SmartBulb.listMetrics().toJson()) |
DTI Members using the Covid-19 DataLake: While listMetrics does return a list, this is fairly bare bones if the 'description' field of a given metric isn't filled in. The Covid-19 DataLake API documentation provides an extensive list of production-ready metrics along with detailed descriptions and usage examples. Please see that documentation here: https://c3.ai/covid-19-api-documentation/
After finding a metric, the next step is to evaluate on data in a C3.ai TypeOnce you have the metric you want to evaluate in mind, you can evaluate it.
Evaluating Metrics
With a metric in mind, you can use the 'evalMetrics' API function which is brought in with the MetricEvaluatable type to actually evaluate the metric. The evalMetrics function takes an 'EvalMetricsSpec' type which contains the following:
...