MCPcopy Index your code
hub / github.com/tensorflow/playground / classifyCircleData

Function classifyCircleData

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

Source from the content-addressed store, hash-verified

154}
155
156export function classifyCircleData(numSamples: number, noise: number):
157 Example2D[] {
158 let points: Example2D[] = [];
159 let radius = 5;
160 function getCircleLabel(p: Point, center: Point) {
161 return (dist(p, center) < (radius * 0.5)) ? 1 : -1;
162 }
163
164 // Generate positive points inside the circle.
165 for (let i = 0; i < numSamples / 2; i++) {
166 let r = randUniform(0, radius * 0.5);
167 let angle = randUniform(0, 2 * Math.PI);
168 let x = r * Math.sin(angle);
169 let y = r * Math.cos(angle);
170 let noiseX = randUniform(-radius, radius) * noise;
171 let noiseY = randUniform(-radius, radius) * noise;
172 let label = getCircleLabel({x: x + noiseX, y: y + noiseY}, {x: 0, y: 0});
173 points.push({x, y, label});
174 }
175
176 // Generate negative points outside the circle.
177 for (let i = 0; i < numSamples / 2; i++) {
178 let r = randUniform(radius * 0.7, radius);
179 let angle = randUniform(0, 2 * Math.PI);
180 let x = r * Math.sin(angle);
181 let y = r * Math.cos(angle);
182 let noiseX = randUniform(-radius, radius) * noise;
183 let noiseY = randUniform(-radius, radius) * noise;
184 let label = getCircleLabel({x: x + noiseX, y: y + noiseY}, {x: 0, y: 0});
185 points.push({x, y, label});
186 }
187 return points;
188}
189
190export function classifyXORData(numSamples: number, noise: number):
191 Example2D[] {

Callers

nothing calls this directly

Calls 2

randUniformFunction · 0.85
getCircleLabelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…