code: public void onlineTrain(final double[] x, final int labelIndex) {
          Map<Integer, Double> result = predict(x);
          Map.Entry<Integer, Double> maxResult = result.entrySet().stream().max((e1, e2) -> e1.getValue().compareTo(e2.getValue())).orElse(null);
  
          if (maxResult.getKey() != labelIndex) {
              double e_correction_d = 1;
              model.weights[labelIndex] = reweight(x, model.weights[labelIndex], e_correction_d);
              model.bias[labelIndex] = e_correction_d;
  
              double w_correction_d = -1;
              model.weights[maxResult.getKey()] = reweight(x, model.weights[maxResult.getKey()], w_correction_d);
              model.bias[maxResult.getKey()] = w_correction_d;
          }
  
          if (LOG.isDebugEnabled()) {
              LOG.debug("New bias: " + Arrays.toString(model.bias));
              LOG.debug("New weight: " + Arrays.stream(model.weights).map(Arrays::toString).reduce((wi, wii) -> wi + ", " + wii).get());
          }
      }
docs: public use for doing one training sample.
  
  @param x          Feature Vector
  @param labelIndex label's index, from PerceptronModel.LabelIndexer