Program: 117211
Project: 117211
Buggy source:
/** 
 * Builds L1-regularized regressors for a sequence of regularization parameter lambdas on sparse format. Each row of the input represents a feature (instead of a data point), i.e., in column-oriented format. This procedure does not assume the data is normalized or centered.
 * @param attrs the attribute list.
 * @param indices the indices.
 * @param values the values.
 * @param maxNumIters the maximum number of iterations.
 * @param numLambdas the number of lambdas.
 * @param minLambdaRatio the minimum lambda is minLambdaRatio * max lambda.
 * @return L1-regularized regressors.
 */
public List<GLM> buildGaussianRegressors(int[] attrs,int[][] indices,double[][] values,double[] y,int maxNumIters,int numLambdas,double minLambdaRatio){
  double[] w=new double[attrs.length];
  double intercept=0;
  double[] rTrain=new double[y.length];
  for (int i=0; i < rTrain.length; i++) {
    rTrain[i]=y[i];
  }
  double[] sq=new double[values.length];
  for (int i=0; i < values.length; i++) {
    sq[i]=StatUtils.sumSq(values[i]);
  }
  double maxLambda=findMaxLambdaGaussian(indices,values,y);
  double alpha=Math.pow(minLambdaRatio,1.0 / numLambdas);
  List<GLM> glms=new ArrayList<>(numLambdas);
  Set<ModelStructure> structures=new HashSet<>();
  double lambda=maxLambda;
  for (int g=0; g < numLambdas; g++) {
    final double tl1=lambda * y.length;
    for (int iter=0; iter < maxNumIters; iter++) {
      double prevLoss=GLMOptimUtils.computeLassoLoss(rTrain,w,lambda);
      if (fitIntercept) {
        intercept+=OptimUtils.fitIntercept(rTrain);
      }
      doOnePassGaussian(indices,values,sq,tl1,w,rTrain);
      double currLoss=GLMOptimUtils.computeLassoLoss(rTrain,w,lambda);
      if (verbose) {
        System.out.println("String_Node_Str" + iter + "String_Node_Str"+ "String_Node_Str"+ currLoss);
      }
      if (OptimUtils.isConverged(prevLoss,currLoss,epsilon)) {
        break;
      }
    }
    lambda*=alpha;
    if (refit) {
      boolean[] selected=new boolean[attrs.length];
      for (int i=0; i < selected.length; i++) {
        selected[i]=w[i] != 0;
      }
      ModelStructure structure=new ModelStructure(selected);
      if (!structures.contains(structure)) {
        GLM glm=refitGaussianRegressor(attrs,selected,indices,values,y,maxNumIters);
        glms.add(glm);
        structures.add(structure);
      }
    }
 else {
      GLM glm=GLMOptimUtils.getGLM(attrs,w,intercept,LinkFunction.IDENTITY);
      glms.add(glm);
    }
  }
  return glms;
}

Fixed version (ground truth):
/** 
 * Builds L1-regularized regressors for a sequence of regularization parameter lambdas on sparse format. Each row of the input represents a feature (instead of a data point), i.e., in column-oriented format. This procedure does not assume the data is normalized or centered.
 * @param attrs the attribute list.
 * @param indices the indices.
 * @param values the values.
 * @param y the targets.
 * @param maxNumIters the maximum number of iterations.
 * @param numLambdas the number of lambdas.
 * @param minLambdaRatio the minimum lambda is minLambdaRatio * max lambda.
 * @return L1-regularized regressors.
 */
public List<GLM> buildGaussianRegressors(int[] attrs,int[][] indices,double[][] values,double[] y,int maxNumIters,int numLambdas,double minLambdaRatio){
  double[] w=new double[attrs.length];
  double intercept=0;
  double[] rTrain=new double[y.length];
  for (int i=0; i < rTrain.length; i++) {
    rTrain[i]=y[i];
  }
  double[] sq=new double[values.length];
  for (int i=0; i < values.length; i++) {
    sq[i]=StatUtils.sumSq(values[i]);
  }
  double maxLambda=findMaxLambdaGaussian(indices,values,y);
  double alpha=Math.pow(minLambdaRatio,1.0 / numLambdas);
  List<GLM> glms=new ArrayList<>(numLambdas);
  Set<ModelStructure> structures=new HashSet<>();
  double lambda=maxLambda;
  for (int g=0; g < numLambdas; g++) {
    final double tl1=lambda * y.length;
    for (int iter=0; iter < maxNumIters; iter++) {
      double prevLoss=GLMOptimUtils.computeLassoLoss(rTrain,w,lambda);
      if (fitIntercept) {
        intercept+=OptimUtils.fitIntercept(rTrain);
      }
      doOnePassGaussian(indices,values,sq,tl1,w,rTrain);
      double currLoss=GLMOptimUtils.computeLassoLoss(rTrain,w,lambda);
      if (verbose) {
        System.out.println("String_Node_Str" + iter + "String_Node_Str"+ "String_Node_Str"+ currLoss);
      }
      if (OptimUtils.isConverged(prevLoss,currLoss,epsilon)) {
        break;
      }
    }
    lambda*=alpha;
    if (refit) {
      boolean[] selected=new boolean[attrs.length];
      for (int i=0; i < selected.length; i++) {
        selected[i]=w[i] != 0;
      }
      ModelStructure structure=new ModelStructure(selected);
      if (!structures.contains(structure)) {
        GLM glm=refitGaussianRegressor(attrs,selected,indices,values,y,maxNumIters);
        glms.add(glm);
        structures.add(structure);
      }
    }
 else {
      GLM glm=GLMOptimUtils.getGLM(attrs,w,intercept,LinkFunction.IDENTITY);
      glms.add(glm);
    }
  }
  return glms;
}