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

Method testClone

JSAT/test/jsat/regression/RANSACTest.java:108–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106 }
107
108 @Test
109 public void testClone()
110 {
111 System.out.println("clone");
112
113 RANSAC instance = new RANSAC(new KernelRLS(new LinearKernel(1), 1e-1), 10, 20, 40, 5);
114
115 RegressionDataSet t1 = FixedProblems.getLinearRegression(500, RandomUtil.getRandom());
116 for(int i = 0; i < 20; i++)
117 t1.addDataPoint(DenseVector.random(t1.getNumNumericalVars()), t1.getTargetValues().mean());
118 RegressionDataSet t2 = FixedProblems.getLinearRegression(100, RandomUtil.getRandom());
119 t2.applyTransform(new LinearTransform(t2, 1, 10));
120
121 instance = instance.clone();
122
123 instance.train(t1);
124
125 RANSAC result = instance.clone();
126 for (int i = 0; i < t1.getSampleSize(); i++)
127 assertEquals(t1.getTargetValue(i), result.regress(t1.getDataPoint(i)), t1.getTargetValues().mean());
128 result.train(t2);
129
130 for (int i = 0; i < t1.getSampleSize(); i++)
131 assertEquals(t1.getTargetValue(i), instance.regress(t1.getDataPoint(i)), t1.getTargetValues().mean());
132
133 for (int i = 0; i < t2.getSampleSize(); i++)
134 assertEquals(t2.getTargetValue(i), result.regress(t2.getDataPoint(i)), t2.getTargetValues().mean()*0.5);
135
136 }
137
138}

Callers

nothing calls this directly

Calls 14

getLinearRegressionMethod · 0.95
getRandomMethod · 0.95
addDataPointMethod · 0.95
getTargetValuesMethod · 0.95
cloneMethod · 0.95
trainMethod · 0.95
getSampleSizeMethod · 0.95
getTargetValueMethod · 0.95
regressMethod · 0.95
getDataPointMethod · 0.95
getNumNumericalVarsMethod · 0.80
applyTransformMethod · 0.80

Tested by

no test coverage detected