MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / get2ClassLinear2D

Method get2ClassLinear2D

JSAT/test/jsat/FixedProblems.java:57–70  ·  view source on GitHub ↗

Creates a 2D linearly separable problem @param dataSetSize0 size of the first class @param dataSetSize1 size of the second class @param sep the separation between the two classes. The true decision boundary stays in the same location regardless of this value @param rand source of randomness @return

(int dataSetSize0, int dataSetSize1, double sep, Random rand)

Source from the content-addressed store, hash-verified

55 * @return a 2d testing set
56 */
57 public static ClassificationDataSet get2ClassLinear2D(int dataSetSize0, int dataSetSize1, double sep, Random rand)
58 {
59 ClassificationDataSet train = new ClassificationDataSet(2, new CategoricalData[0], new CategoricalData(2));
60
61 NormalM a = new NormalM(DenseVector.toDenseVec(sep, sep), Matrix.eye(2));
62 NormalM b = new NormalM(DenseVector.toDenseVec(-sep, -sep), Matrix.eye(2));
63
64 for(Vec s : a.sample(dataSetSize0, rand))
65 train.addDataPoint(s, new int[0], 0);
66 for(Vec s : b.sample(dataSetSize1, rand))
67 train.addDataPoint(s, new int[0], 1);
68
69 return train;
70 }
71
72 /**
73 * Generates a linearly separable binary classification problem

Calls 4

toDenseVecMethod · 0.95
eyeMethod · 0.95
sampleMethod · 0.95
addDataPointMethod · 0.95

Tested by

no test coverage detected