@Override
 public List<Integer> batchRetrieve(
     final MlStormWekaState binaryClassifierState, final List<TridentTuple> queryTuples) {
   List<Integer> queryResults = new ArrayList<Integer>();
   for (TridentTuple queryTuple : queryTuples) {
     double[] fv = getFeatureVectorFromArgs(queryTuple);
     final Instance instance = MlStormFeatureVectorUtils.buildWekaInstance(fv);
     try {
       final int classification = (int) binaryClassifierState.predict(instance);
       queryResults.add(classification);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return queryResults;
 }
    @Override
    public List<Map.Entry<Double, double[]>> batchRetrieve(
        final MlStormWekaState clustererState, final List<TridentTuple> queryTuples) {
      ArrayList<Map.Entry<Double, double[]>> queryResults =
          new ArrayList<Map.Entry<Double, double[]>>();
      for (TridentTuple query : queryTuples) {

        //noinspection unchecked
        final Map<Integer, Map.Entry<Integer, double[]>> voteMap =
            (Map<Integer, Map.Entry<Integer, double[]>>) query.getValueByField("voteMap");
        final double[] fv = new double[numPartitions];

        for (Integer key : voteMap.keySet()) {
          fv[key] = voteMap.get(key).getKey();
        }

        try {
          Instance testInstance = MlStormFeatureVectorUtils.buildWekaInstance(fv);
          double[] distribution = null;
          double result = clustererState.predict(testInstance);
          queryResults.add(new KeyValuePair<Double, double[]>(result, distribution));

        } catch (IOException e) {
          e.printStackTrace();
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        } catch (Exception e) {
          if (e.toString().contains(MlStormWekaState.NOT_READY_TO_PREDICT)) {
            System.err.println(
                MessageFormat.format(
                    "Not Ready yet! Continue training with - {0}", Arrays.toString(fv)));
            queryResults.add(new KeyValuePair<Double, double[]>(fv[fv.length - 1], null));
          } else {
            throw new IllegalStateException(e);
          }
        }
      }
      return queryResults;
    }