demo D268
ROC curve in Angular
See how well a score separates two outcomes, the curve bowing away from a coin toss
type: 'roc', score, label, positive
This draws an ROC curve showing how well a score separates two outcomes, the curve bowing away from a coin-toss line. It shows a classifier's quality at a glance, so how much better than chance it does reads as the bow of the curve.
This is the Angular version. A standalone component takes the whole configuration through one config input, surfaces grid events as outputs, and exposes the live grid on a getter for anything the inputs do not cover.
The configuration
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-roc'; // opt in to the roc type
import { LatticeGridComponent, provideLattice } from '@toclocoinc/lattice-grid/angular';
@Component({
selector: 'app-root',
standalone: true,
imports: [LatticeGridComponent],
template:
'<div id="chart" style="height:340px"></div>' +
'<lattice-grid [config]="grid" style="display:block;height:320px;margin-top:14px"></lattice-grid>',
})
export class AppComponent implements AfterViewInit {
@ViewChild(LatticeGridComponent) gridRef!: LatticeGridComponent;
grid = {
rowKey: 'id',
columns: [
{ field: 'score', title: 'Score', type: 'number', format: { decimals: 3 } },
{ field: 'fraud', title: 'Actually fraud', type: 'number', filter: { type: 'set' } },
],
rows: [/* one row a case: score, fraud (1 for positive, 0 otherwise) */],
};
ngAfterViewInit() {
createChart({ grid: this.gridRef.grid, container: '#chart', type: 'roc', score: 'score', label: 'fraud', positive: 1, title: 'How well the score separates fraud' });
}
}
bootstrapApplication(AppComponent, {
providers: [provideLattice({ createGrid })],
});