code: @Override
      public int predict(T x) {
          double minDist = Double.MAX_VALUE;
          int bestCluster = 0;
  
          for (int i = 0; i < k; i++) {
              double dist = distance.d(x, medoids[i]);
              if (dist < minDist) {
                  minDist = dist;
                  bestCluster = i;
              }
          }
  
          return bestCluster;
      }
docs: Cluster a new instance.
  @param x a new instance.
  @return the cluster label, which is the index of nearest medoid.