plot_data = {
const finished = model.history.length === model.max_steps;
const h = finished ? 0.1 : 0.25;
const xMin = d3.min(X, (i) => i[0]) - 1;
const xMax = d3.max(X, (i) => i[0]) + 1;
const yMin = d3.min(X, (i) => i[1]) - 1;
const yMax = d3.max(X, (i) => i[1]) + 1;
const xx = d3.range(xMin, xMax, h);
const yy = d3.range(yMin, yMax, h);
const Xmesh = [];
for (let i = 0; i < xx.length; i++) {
for (let j = 0; j < yy.length; j++) {
Xmesh.push([xx[i], yy[j]]);
}
}
const inputs = Xmesh.map((xrow) => xrow.map((x) => new Value(x)));
const scores = inputs.map((input) => model.model.call(input)[0]);
const Z = scores.map((s) => (s.data > 0 ? 1 : -1));
const decision_boundary = Xmesh.map((point, i) => ({
x: point[0],
y: point[1],
color: scores[i].data
}));
const original_data = X.map((point, i) => ({
x: point[0],
y: point[1],
color: y[i]
}));
return { step: h / 1.9, original_data, decision_boundary };
}