public static SumSquaresRatio[] fit(DataFrame data, String clazz) {
        BaseVector<?, ?, ?> y = data.column(clazz);
        ClassLabels codec = ClassLabels.fit(y);

        if (codec.k < 2) {
            throw new UnsupportedOperationException("Invalid number of classes: " + codec.k);
        }

        int n = data.nrow();
        int k = codec.k;
        int[] nc = new int[k];
        double[] condmu = new double[k];

        for (int i = 0; i < n; i++) {
            int yi = codec.y[i];
            nc[yi]++;
        }

        StructType schema = data.schema();

        return IntStream.range(0, schema.length()).mapToObj(j -> {
            StructField field = schema.field(j);
            if (field.isNumeric()) {
                BaseVector<?, ?, ?> xj = data.column(j);
                double mu = 0.0;
                Arrays.fill(condmu, 0.0);
                for (int i = 0; i < n; i++) {
                    int yi = codec.y[i];
                    double xij = xj.getDouble(i);
                    mu += xij;
                    condmu[yi] += xij;
                }

                mu /= n;
                for (int i = 0; i < k; i++) {
                    condmu[i] /= nc[i];
                }

                double wss = 0.0;
                double bss = 0.0;

                for (int i = 0; i < n; i++) {
                    int yi = codec.y[i];
                    double xij = xj.getDouble(i);
                    bss += MathEx.pow2(condmu[yi] - mu);
                    wss += MathEx.pow2(xij - condmu[yi]);
                }

                return new SumSquaresRatio(field.name, bss / wss);
            } else {
                return null;
            }
        }).filter(s2n -> s2n != null && !s2n.feature.equals(clazz)).toArray(SumSquaresRatio[]::new);
    }
@Test
    public void testIris() {
        System.out.println("Iris");
        SumSquaresRatio[] ssr = SumSquaresRatio.fit(Iris.data, "class");
        assertEquals(4, ssr.length);
        assertEquals( 1.6226463, ssr[0].ssr, 1E-6);
        assertEquals( 0.6444144, ssr[1].ssr, 1E-6);
        assertEquals(16.0412833, ssr[2].ssr, 1E-6);
        assertEquals(13.0520327, ssr[3].ssr, 1E-6);
    }