### Question:
AutomaticGramBuilder { public FeatureWeightMap build(ProgressReporter reporter) throws ApplicationException { featureList.validate(); int[] ixPos = MatrixUtils.find(labels, 1d); int[] ixNeg = MatrixUtils.find(labels, -1d); final int numPos = ixPos.length; final int numNeg = ixNeg.length; final int numFeatures = featureList.size(); final int numPosPos = numPos * (numPos - 1); final int numPosNeg = 2 * numPos * numNeg; final double biasVal = 1d/ (numPosPos + numPosNeg); final double posConst = (2d * numNeg) / (numPos + numNeg); final double negConst = (-2d * numPos) / (numPos + numNeg); final double posPosTarget = posConst * posConst; final double posNegTarget = posConst * negConst; DenseMatrix KtK = new DenseMatrix(numFeatures, numFeatures); DenseVector KtT = new DenseVector(numFeatures); KtK.set(0, 0, biasVal); double sumOfTargets = posPosTarget * numPosPos + posNegTarget * numPosNeg; KtT.set(0, biasVal * sumOfTargets); SymMatrix[] Wpp = new SymMatrix[numFeatures]; Matrix[] Wpn = new Matrix[numFeatures]; boolean oldMode = false; boolean scaled = true; FeatureLoader featureLoader = new FeatureLoader(cache, namespace, organismId, oldMode, scaled); for (int ii = 1; ii<numFeatures; ii++) { Feature feature_ii = featureList.get(ii); Wpp[ii] = featureLoader.load(feature_ii, ixPos); Wpn[ii] = featureLoader.load(feature_ii, ixPos, ixNeg); double ssWpp = Wpp[ii].elementSum(); double ssWpn = Wpn[ii].elementSum(); KtT.set(ii, posPosTarget * ssWpp + 2d * posNegTarget * ssWpn); KtK.set(ii, 0, biasVal * (ssWpp + 2 * ssWpn)); KtK.set(0, ii, KtK.get(ii, 0)); for (int jj = 1; jj <= ii; jj++) { if (progress.isCanceled()) { throw new CancellationException(); } double sumOfProds = 0; sumOfProds += Wpp[ii].elementMultiplySum(Wpp[jj]); sumOfProds += 2 * Wpn[ii].elementMultiplySum(Wpn[jj]); KtK.set(ii, jj, sumOfProds); KtK.set(jj, ii, sumOfProds); } } logger.debug("solving system of size " + featureList.size()); return Solver.solve(KtK, KtT, featureList, progress); } AutomaticGramBuilder(DataCache cache, String namespace, long organismId, FeatureList featureList, Vector labels, ProgressReporter progress); FeatureWeightMap build(ProgressReporter reporter);  }### Answer:
@Test public void testBuild() throws ApplicationException { Vector labels = getLabels(config.getOrg1numGenes(), config.getOrg1numGenes()/2); FeatureList features = getFeatures(); AutomaticGramBuilder builder = new AutomaticGramBuilder(cacheBuilder.getCache(), Data.CORE, config.getOrg1Id(), features, labels, NullProgressReporter.instance()); FeatureWeightMap weights = builder.build(NullProgressReporter.instance()); assertNotNull(weights); }