MCPcopy
hub / github.com/tensorflow/playground / classifyXORData

Function classifyXORData

src/dataset.ts:190–207  ·  view source on GitHub ↗
(numSamples: number, noise: number)

Source from the content-addressed store, hash-verified

188}
189
190export function classifyXORData(numSamples: number, noise: number):
191 Example2D[] {
192 function getXORLabel(p: Point) { return p.x * p.y >= 0 ? 1 : -1; }
193
194 let points: Example2D[] = [];
195 for (let i = 0; i < numSamples; i++) {
196 let x = randUniform(-5, 5);
197 let padding = 0.3;
198 x += x > 0 ? padding : -padding; // Padding.
199 let y = randUniform(-5, 5);
200 y += y > 0 ? padding : -padding;
201 let noiseX = randUniform(-5, 5) * noise;
202 let noiseY = randUniform(-5, 5) * noise;
203 let label = getXORLabel({x: x + noiseX, y: y + noiseY});
204 points.push({x, y, label});
205 }
206 return points;
207}
208
209/**
210 * Returns a sample from a uniform [a, b] distribution.

Callers

nothing calls this directly

Calls 2

randUniformFunction · 0.85
getXORLabelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…