@Override
    public Neighbor<double[], E> nearest(double[] q) {
        if (model == null) return super.nearest(q);
        return nearest(q, 0.95, 100);
    }
@Test
    public void testNearest() {
        System.out.println("nearest");

        int recall = 0;
        double error = 0.0;
        int hit = 0;
        for (double[] xi : testx) {
            Neighbor neighbor = lsh.nearest(xi);
            if (neighbor != null) {
                hit++;

                Neighbor truth = naive.nearest(xi);
                if (neighbor.index == truth.index) {
                    recall++;
                } else {
                    error += Math.abs(neighbor.distance - truth.distance) / truth.distance;
                }
            }
        }

        error /= (hit - recall);

        assertEquals(1722, recall);
        assertEquals(2007, hit);
        assertEquals(0.0687, error, 1E-4);
        System.out.format("recall is %.2f%%%n", 100.0 * recall / testx.length);
        System.out.format("error when miss is %.2f%%%n", 100.0 * error);
        System.out.format("null rate is %.2f%%%n", 100.0 - 100.0 * hit / testx.length);
    }