code: private static LinearModel trainAveragedPerceptron(Instance[] instanceList, FeatureMap featureMap, int maxIteration)
      {
          float[] parameter = new float[featureMap.size()];
          double[] sum = new double[featureMap.size()];
          int[] time = new int[featureMap.size()];
  
          AveragedPerceptron model = new AveragedPerceptron(featureMap, parameter);
          int t = 0;
          for (int it = 0; it < maxIteration; ++it)
          {
              Utility.shuffleArray(instanceList);
              for (Instance instance : instanceList)
              {
                  ++t;
                  int y = model.decode(instance.x);
                  if (y != instance.y) // 误差反馈
                      model.update(instance.x, instance.y, sum, time, t);
              }
          }
          model.average(sum, time, t);
          return model;
      }
docs: 平均感知机训练算法
  @param instanceList 训练实例
  @param featureMap   特征函数
  @param maxIteration 训练迭代次数