code: public void impute(double[][] data, int maxIter) throws MissingValueImputationException {
          if (maxIter < 1) {
              throw new IllegalArgumentException("Invalid maximum number of iterations: " + maxIter);
          }
  
          int[] count = new int[data[0].length];
          for (int i = 0; i < data.length; i++) {
              int n = 0;
              for (int j = 0; j < data[i].length; j++) {
                  if (Double.isNaN(data[i][j])) {
                      n++;
                      count[j]++;
                  }
              }
  
              if (n == data[i].length) {
                  throw new MissingValueImputationException("The whole row " + i + " is missing");
              }
          }
  
          for (int i = 0; i < data[0].length; i++) {
              if (count[i] == data.length) {
                  throw new MissingValueImputationException("The whole column " + i + " is missing");
              }
          }
  
          double[][] full = new double[data.length][];
          for (int i = 0; i < full.length; i++) {
              full[i] = data[i].clone();
          }
  
          KMeansImputation.columnAverageImpute(full);
  
          for (int iter = 0; iter < maxIter; iter++) {
              svdImpute(data, full);
          }
  
          for (int i = 0; i < data.length; i++) {
              System.arraycopy(full[i], 0, data[i], 0, data[i].length);
          }
      }
docs: Impute missing values in the dataset.
  @param data a data set with missing values (represented as Double.NaN).
  On output, missing values are filled with estimated values.
  @param maxIter the maximum number of iterations.