MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / plotData

Function plotData

polynomial-regression-core/ui.js:20–41  ·  view source on GitHub ↗
(container, xs, ys)

Source from the content-addressed store, hash-verified

18 import renderChart from 'vega-embed';
19
20 export async function plotData(container, xs, ys) {
21 const xvals = await xs.data();
22 const yvals = await ys.data();
23
24 const values = Array.from(yvals).map((y, i) => {
25 return {'x': xvals[i], 'y': yvals[i]};
26 });
27
28 const spec = {
29 '$schema': 'https://vega.github.io/schema/vega-lite/v2.json',
30 'width': 300,
31 'height': 300,
32 'data': {'values': values},
33 'mark': 'point',
34 'encoding': {
35 'x': {'field': 'x', 'type': 'quantitative'},
36 'y': {'field': 'y', 'type': 'quantitative'}
37 }
38 };
39
40 return renderChart(container, spec, {actions: false});
41 }
42
43 export async function plotDataAndPredictions(container, xs, ys, preds) {
44 const xvals = await xs.data();

Callers 1

learnCoefficientsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected