### Question:
GaussianProcessPrior extends WeightLearningApplication { @Override protected void doLearn() { kernel = GaussianProcessKernel.makeKernel(kernelType, this); reset(); List<Float> exploredFnVal = new ArrayList<Float>(); WeightConfig bestConfig = null; float bestVal = 0.0f; boolean allStdSmall = false; int iteration = 0; while (iteration < maxIterations && configs.size() > 0 && !(earlyStopping && allStdSmall)) { int nextPoint = getNextPoint(configs, iteration); WeightConfig config = configs.get(nextPoint); exploredConfigs.add(config); configs.remove(nextPoint); float fnVal = getFunctionValue(config); exploredFnVal.add(fnVal); config.valueAndStd.value = fnVal; config.valueAndStd.std = 0.0f; if (bestConfig == null || fnVal > bestVal) { bestVal = fnVal; bestConfig = config; } log.info(String.format("Iteration %d -- Config Picked: %s, Curent Best Config: %s.", (iteration + 1), exploredConfigs.get(iteration), bestConfig)); int numKnown = exploredFnVal.size(); knownDataStdInv = FloatMatrix.zeroes(numKnown, numKnown); for (int i = 0; i < numKnown; i++) { for (int j = 0; j < numKnown; j++) { knownDataStdInv.set(i, j, kernel.kernel(exploredConfigs.get(i).config, exploredConfigs.get(j).config)); } } knownDataStdInv = knownDataStdInv.inverse(); blasYKnown = FloatMatrix.columnVector(ListUtils.toPrimitiveFloatArray(exploredFnVal), false); ComputePredictionFunctionValueWorker fnValWorker = new ComputePredictionFunctionValueWorker(); int index = 0; for (WeightConfig weightConfig : configs) { fnValWorker.work(index, weightConfig); index++; } allStdSmall = true; for (int i = 0; i < configs.size(); i++) { if (configs.get(i).valueAndStd.std > SMALL_VALUE) { allStdSmall = false; break; } } iteration++; } setWeights(bestConfig); log.info(String.format("Total number of iterations completed: %d. Stopped early: %s.", iteration, (earlyStopping && allStdSmall))); log.info("Best config: " + bestConfig); } GaussianProcessPrior(List<Rule> rules, Database rvDB, Database observedDB);  GaussianProcessPrior(Model model, Database rvDB, Database observedDB);  static final String CONFIG_PREFIX; static final String KERNEL_KEY; static final String KERNEL_DEFAULT; static final String MAX_ITERATIONS_KEY; static final int MAX_ITERATIONS_DEFAULT; static final String MAX_CONFIGS_KEY; static final int MAX_CONFIGS_DEFAULT; static final String EXPLORATION_KEY; static final float EXPLORATION_DEFAULT; static final String RANDOM_CONFIGS_ONLY_KEY; static final boolean RANDOM_CONFIGS_ONLY_DEFAULT; static final String EARLY_STOPPING_KEY; static final boolean EARLY_STOPPING_DEFAULT; static final int MAX_RAND_INT_VAL; static final float SMALL_VALUE; }### Answer:
@Test public void testDoLearn() { Config.setProperty(GaussianProcessKernel.REL_DEP_KEY, 1); Config.setProperty(GaussianProcessKernel.SPACE_KEY, GaussianProcessKernel.Space.OS); Config.setProperty(GaussianProcessPrior.MAX_CONFIGS_KEY, 5); Config.setProperty(GaussianProcessPrior.MAX_ITERATIONS_KEY, 3); Config.setProperty(GaussianProcessPrior.KERNEL_KEY, GaussianProcessKernel.KernelType.SQUARED_EXP); Config.setProperty(GaussianProcessPrior.RANDOM_CONFIGS_ONLY_KEY, false); GaussianProcessPrior wl = (GaussianProcessPrior) getWLALocal(); wl.doLearn(); for (int i = 0; i < 3; i++) { Assert.assertEquals(1.0f, ((WeightedRule)this.info.model.getRules().get(i)).getWeight(), 1e-30); } }