@Override
    public int predict(double[] x) {
        if (x.length != p) {
            throw new IllegalArgumentException(String.format("Invalid input vector size: %d, expected: %d", x.length, p));
        }

        double[] wx = project(x);

        int y = 0;
        double nearest = Double.POSITIVE_INFINITY;
        for (int i = 0; i < k; i++) {
            double d = MathEx.distance(wx, mu[i]);
            if (d < nearest) {
                nearest = d;
                y = i;
            }
        }

        return classes.valueOf(y);
    }
@Test
    public void testUSPS() throws Exception {
        System.out.println("USPS");

        ClassificationValidation<FLD> result = ClassificationValidation.of(USPS.x, USPS.y, USPS.testx, USPS.testy, FLD::fit);

        System.out.println(result);
        assertEquals(262, result.metrics.error);

        java.nio.file.Path temp = Write.object(result.model);
        FLD model = (FLD) Read.object(temp);

        int error = Error.of(USPS.testy, model.predict(USPS.testx));
        assertEquals(262, error);
    }