OpenBI Docs Buy

Charts and visuals

Charts a step shows (bars, lines, reliability, SHAP, loss and survival curves) and any of OpenBI's report visuals drawn under a step on the model's measures.

Chart

public static class Chart

Charts for steps to show with Display.

Methods

static ChartSpec Reliability(double[] probability, double[] outcome, int bins = 10, string title = "How often it happened, against the probability given")
The reliability diagram: per bin of scores, how often its rows had the outcome against the bin's mean score (the line it should follow). Above it, the model said too little; below, too much.
static ChartSpec Qini(QiniCurve q, string title = "Extra outcomes by the share targeted, highest uplift first")
The Qini curve (Uplift.Qini) against treating at random: the higher above the straight line, the better the uplift ranking.
static ChartSpec Tenths(double[] score, double[] outcome, string title = "How often it happened, by how likely it was rated")
Of the rows in each tenth by score (highest first), how many had the outcome; the dashed line is all rows.
static ChartSpec Survival(double[] risk, double[] time, double[] evt, string title = "Still without the event, by the risk it rated them", double? until = null)
Survival by the risk a model rated rows (the test rows' Kaplan-Meier curves, a third each: the riskiest, the middle, the safest): curves far apart are a model that tells who has the event first.
static ChartSpec History(ForecastHistory history, string? title = null)
A history's total per period (every series together).
static ChartSpec Forecast(ForecastHistory history, Table forecast, string? title = null)
What happened and what is forecast, every series together: the history's totals, and the forecast's (history.Score's rows: the median and the range from the 10th to the 90th percentile, summed).
static ChartSpec Loss(Booster booster)
The metric after each iteration on the training rows and on the validation rows, two lines in one chart: the best iteration (the trees the model keeps) marked with a dot and a line, and where early stopping ended the training. The training line far below the validation line (above, for a metric where higher is better, as auc) is the model learning its training rows by heart. Its summary says both values at the best iteration. It draws no held-out test line, on purpose: the validation rows are the ones the trees are chosen on, and a test watched iteration by iteration would be chosen on too - the bias the held-out test is there to avoid. The test is measured once, at the trees chosen (the patterns' evaluate step), and kept with the version (Models.Save heldOut:).
static ChartSpec Loss(CrossValidation cv)
A cross-validation's curves: each fold's metric on its training rows and on its validation rows after each iteration (a thin line each; training orange, validation blue), each fold's best iteration a dot on its validation line, and the trees the final model learns with (the folds' mean best iteration) marked. Folds far apart are a metric that depends on the rows it is checked on; training lines far from the validation lines are overfitting.
static ChartSpec Shap(Booster booster, Table rows, int top = 12, int sample = 1000, IReadOnlyList<string>? names = null)
SHAP's summary, as the shap package draws it (a beeswarm): a row per feature, the strongest first (its mean absolute contribution); each dot one of the rows (up to sample of them), at how much that feature moved its score (left: lowered, right: raised), colored by the feature's value among the rows (blue low, red high, grey missing). names: the columns that name a row, shown on hover with the feature's value (by default the first text and date columns that aren't features).
static ChartSpec ShapDependence(Booster booster, Table rows, string feature, int sample = 2000, IReadOnlyList<string>? names = null)
A feature's value against how much it moved each row's score (SHAP's dependence plot): where it helps, where it hurts.
static ChartSpec ShapWaterfall(Booster booster, Table row, int top = 10)
Why one row scored as it did (SHAP's waterfall): from the model's base value, each feature's push up or down, the strongest first (the rest together), to the row's raw score.
static ChartSpec Drivers(Booster booster, Table rows, int top = 12)
What moves the score most over these rows: the mean absolute SHAP contribution of each feature.

Also: static ChartSpec Bar(string title, IReadOnlyList<string> categories, params ChartSeries[] series), static ChartSpec Line(string title, IReadOnlyList<string> categories, params ChartSeries[] series), static ChartSpec HBar(string title, IReadOnlyList<string> categories, IReadOnlyList<double> values).

ChartSpec

public sealed record ChartSpec(
    string Kind,
    string Title,
    IReadOnlyList<string> Categories,
    IReadOnlyList<ChartSeries> Series)

A chart a step shows: bars, horizontal bars or lines over categories, with an optional reference line and a marked point. The studio draws it; the notebook file also keeps it as SVG, so Jupyter and VS Code show it too.

Properties

string Format { get; init; }
"percent" or "number": how values are written.
int? Marker { get; init; }
A category to mark (the best iteration of a loss curve).
IReadOnlyList<ChartMark>? Marks { get; init; }
More categories to mark, each with its label (where training stopped early).
string? Summary { get; init; }
What the chart shows, in a sentence with its numbers (for whoever reads the step's text: the agent); else its title.
IReadOnlyList<ChartPoint>? Points { get; init; }
A chart of points (beeswarm, dependence): its points.
IReadOnlyList<string>? PointNames { get; init; }
A chart of points: the name of each row of data its points came from (a point's Item), shown on hover.
IReadOnlyList<IReadOnlyList<string>?>? RowCategories { get; init; }
A chart of points: for each of its rows (features), a categorical feature's categories (a value is one's number), else null.

Also: string Kind { get; init; }, string Title { get; init; }, IReadOnlyList<string> Categories { get; init; }, IReadOnlyList<ChartSeries> Series { get; init; }, double? Reference { get; init; }, string? ReferenceLabel { get; init; }, string? MarkerLabel { get; init; }, string? XTitle { get; init; }, string? YTitle { get; init; }.

Methods

IReadOnlyList<(string Text, ChartSeries Style, int Color)> LegendEntries()
The legend: one entry per legend name (a series' Legend, else its Name), the first such series' style, in order.
IReadOnlyList<ChartMark> AllMarks()
Every marked category (the marker, then the marks): its index and label.
string PointText(int index)
What a point of a beeswarm or dependence plot says on hover: its row of data, the feature's value there and how much it moved that row's score.
int RowsHeight(int height)
Its height when its rows set it (horizontal bars, a beeswarm, a waterfall of a row): a row each.
static (byte R, byte G, byte B) Heat(double c)
A color from blue (0, low) through purple to red (1, high); grey when unknown, as the shap package colors values.
(double Lo, double Hi) Axis(IReadOnlyList<double> values)
The value axis: bars from zero, lines over their own range with a little room.
string ToSvg(int width = 560, int height = 240)
The chart as an SVG image (for the notebook file and the model card).
static double Jitter(int i)
A dot's place within its row, from -0.5 to 0.5: the same every time (the golden ratio's steps).

Also: JsonObject ToJson(), static ChartSpec FromJson(JsonObject o), string ValueText(double v).

ChartSeries

public sealed record ChartSeries(
    string Name,
    IReadOnlyList<double> Values)

A series of a chart: a name and one value per category (NaN: none there), and how it is drawn.

Properties

int? Color { get; init; }
Its color, the palette's nth (0 blue, 1 orange, 2 green, 3 purple); by default its place among the series.
bool Dashed { get; init; }
A line drawn dashed.
bool Faint { get; init; }
A line drawn thin and light: one of several alike (a cross-validation's folds).
string? Legend { get; init; }
Its name in the legend (null: its name); series with the same legend show there once.
int? Dot { get; init; }
A category to mark with a dot on this line (its best iteration), or null.

Also: string Name { get; init; }, IReadOnlyList<double> Values { get; init; }.

ChartPoint

public sealed record ChartPoint(
    int Row,
    double X,
    double Y,
    double C,
    int Item = -1,
    double Value = double.NaN)

A point of a chart of points: its row (a beeswarm's feature), x, y and its color from 0 (low, blue) to 1 (high, red), NaN grey; the row of data it came from (its name in ChartSpec.PointNames, -1 for none) and the feature's value there.

Properties

Its properties: int Row { get; init; }, double X { get; init; }, double Y { get; init; }, double C { get; init; }, int Item { get; init; }, double Value { get; init; }.

ChartMark

public sealed record ChartMark(int Index, string Label)

A category a chart marks with a vertical line and a label (where a model stopped early).

Properties

Its properties: int Index { get; init; }, string Label { get; init; }.

Visual

public static class Visual

A report visual in a notebook: OpenBI's own components (obi-chart, obi-matrix, obi-kpi, obi-table, obi-map, obi-network, obi-canvas … as reports.md has them), drawn by the report runtime against the model as on a report page, in the report's theme, without the report's filters on all pages. In the studio it is live (its tooltips, its play axis); the picture it keeps (image/png, drawn light) is what the notebook's PDF and Jupyter show.

Visual.Chart("line", "'Date'[Month]", "[Liter]", title: "Liter by month") Visual.Of("obi-chart", new { type = "scatter", x = "[Price]", y = "[Liter]", series = "'Product'[Land]", play = "'Date'[Year]" }) Visual.Html("<obi-kpi measure=\"[Liter]\" compare=\"[Liter LY]\"></obi-kpi>") Visual.Page("sales") 

Methods

static DisplayData Html(string markup, int height = 0, string? title = null)
The markup of one or more components (as on a report page). Height: the visual's own, in pixels (0: as tall as it draws). Title: what the notebook (and its PDF's caption) calls it; else the component's title.
static DisplayData Of(string component, object? attributes = null, int height = 0, string? title = null)
One component and its attributes: an object's properties (seriesSort or series_sort: series-sort) or a dictionary. true sets an attribute on, false and null leave it out, a list is joined with ", ".
static DisplayData Chart(string type, string x, string y, string? series = null, string? where = null, string? title = null, int height = 0)
A chart (column, bar, line, area, scatter, pie, …): x's members, y's measures, series' colors; where filters it in OAX.
static DisplayData Kpi(string measure, string? compare = null, string? trend = null, string? title = null)
A measure's figure: against compare (last year's), with its trend over a date column.
static DisplayData Matrix(string rows, string values, string? columns = null, string? where = null, string? title = null, int height = 0)
A matrix: rows and columns of members, the values' measures in its cells.
static DisplayData Page(string page, int height = 0)
A report page of the project (reports/<page>.html), whole: its filters, its slicers, its visuals.

Last updated · OpenBI Studio 0.3.78