C3 AI Documentation Home

C3 AI Expression

The C3 AI Expression node allows users to create a custom compound metric for evaluation.

Compound metrics are built on top of simple and other compound metrics to produce increasingly complex transformations of data. They are frequently used to create features for use in machine learning models.

To learn more about compound metrics, and metrics in general, visit the C3 AI documentation site at docs.c3.ai.

Prerequisites

The user must be in the appropriate Admin Group and have the correct roles to be authorized to read data from the selected C3 Type. By default, C3 AI follows the principle of least privilege and users may not have been granted access to retrieve data from C3 Types. Please speak to the C3 AI Support Team to ensure proper setup.

Configuration

FieldRequiredDefaultDescription
NameNoneA user-specified node name displayed in the canvas
Output Column NameNoneThe column name to be shown if the expression is connected to a C3 AI Evaluate Analytics node.
Expression (Starting from End of Path)NoneUser defined expression to be used for evaluation. Expression to create compound metric. Expressions can use logical and mathematical operators from Javascript (e.g., +, -, *, /, &&, ||) or any function available in the ExpressionEngineFunction

Node Inputs/Outputs

The node takes a C3 AI Type node as an input. Connect the C3 AI Expression node to a C3 AI Evaluate Analytics node and specify a date range/interval to retrieve the desired data as a dataframe.

The following image shows how to connect the nodes:

Example of retrieving output from an Expression node

Examples

The example is based on creating a new custom metric from a set of ServicePoints. A ServicePoint represents a service delivery point or customer using electricity in their home.

Connect a C3 AI Type node with ServicePoint selected to the C3 AI Expression node, as shown in the following image:

C3 AI Type node connected to a C3 AI Expression node

The C3 AI Expression node needs a column name, which becomes the column name in the Visual Notebooks dataframe after metric evaluation. In this example, "TotalBilled" is used.

A user defined expression is entered in the "Expression" field. Expressions can use logical and mathematical operators from Javascript (e.g., +, -, *, /, &&, ||) or any function available in the ExpressionEngineFunction. The example does a simple sum of two SimpleMetrics--the ElectricityDemandBilled and NaturalGasDemandBilled--to create a "TotalBilled" feature.

Name the new feature column and enter an expression, as shown in the following image:

Example of a C3 AI Expression node configuration

Commonly used functions

The following table shows additional common functions used in compound metrics:

CategoryFunctions
Aggregate Functionsmin, max, avg, sum, and, or, count, median, stddev, variance
Time Series Transformationsrolling, window, eval, aggregate, available, linearDecay, exponentialDecay, fillMissing, interpolate, percentile, rollingDiff, rollup, scaleMinMax, scaleStandard, removeOutliers
Arithmetic Functionsceil, floor, round, abs, random, cos, acos, sin, asin, tan, atan, cuberoot, dotProduct, exp, log, pow, sqrt
String Functionsconcat, contains, startsWith, endsWith, length, join, lowerCase, upperCase, matchCount, matchesRegex, findAll, replace, substring, split
Type Casting Functionsstring, number, dateTime, bool, data, convertToUnit
Miscellaneous Functionsexists, not, intersects, unique, count, ascending, descending, harvesineDistance, map, identity
Time FunctionsdayOfWeek, daysInYear, earliest, latest, year, month, day, hour, minute, second, timeComponent, start, end, interval, period
Was this page helpful?