code: public SVM<T> train(T[] x, int[] y, double[] weight) {
              SVM<T> svm = null;
              if (k == 2) {
                  svm = new SVM<>(kernel, Cp, Cn);
              } else {
                  if (this.weight == null) {
                      svm = new SVM<>(kernel, Cp, k, strategy);
                  } else {
                      svm = new SVM<>(kernel, Cp, this.weight, strategy);
                  }
              }
              
              svm.setTolerance(tol);
              for (int i = 1; i <= epochs; i++) {
                  svm.learn(x, y, weight);
              }
              
              svm.finish();
              return svm;
          }
docs: Learns a SVM classifier with given training data.
  @param x training instances.
  @param y training labels in [0, k), where k is the number of classes.
  @param weight instance weight. Must be positive. The soft margin penalty
  for instance i will be weight[i] * C.
  @return trained SVM classifier