StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.4 KiB
58 lines
1.4 KiB
import {Transform} from 'vega-dataflow';
|
|
import {accessorName, inherits} from 'vega-util';
|
|
|
|
/**
|
|
* Computes extents (min/max) for a data field.
|
|
* @constructor
|
|
* @param {object} params - The parameters for this operator.
|
|
* @param {function(object): *} params.field - The field over which to compute extends.
|
|
*/
|
|
export default function Extent(params) {
|
|
Transform.call(this, [undefined, undefined], params);
|
|
}
|
|
|
|
Extent.Definition = {
|
|
"type": "Extent",
|
|
"metadata": {},
|
|
"params": [
|
|
{ "name": "field", "type": "field", "required": true }
|
|
]
|
|
};
|
|
|
|
var prototype = inherits(Extent, Transform);
|
|
|
|
prototype.transform = function(_, pulse) {
|
|
var extent = this.value,
|
|
field = _.field,
|
|
min = extent[0],
|
|
max = extent[1],
|
|
mod;
|
|
|
|
mod = pulse.changed()
|
|
|| pulse.modified(field.fields)
|
|
|| _.modified('field');
|
|
|
|
if (mod || min == null) {
|
|
min = +Infinity;
|
|
max = -Infinity;
|
|
}
|
|
|
|
pulse.visit(mod ? pulse.SOURCE : pulse.ADD, function(t) {
|
|
var v = field(t);
|
|
if (v != null) {
|
|
// coerce to number
|
|
v = +v;
|
|
// NaNs will fail all comparisons!
|
|
if (v < min) min = v;
|
|
if (v > max) max = v;
|
|
}
|
|
});
|
|
|
|
if (!Number.isFinite(min) || !Number.isFinite(max)) {
|
|
let name = accessorName(field);
|
|
if (name) name = ` for field "${name}"`;
|
|
pulse.dataflow.warn(`Infinite extent${name}: [${min}, ${max}]`);
|
|
min = max = undefined;
|
|
}
|
|
this.value = [min, max];
|
|
};
|
|
|