public double getAccuracy(Matrix features, Matrix labels) {
        double sum = 0;
        for (int i = 0; i < labels.getNumRows(); i++) {

            List<Double> result = predict(features.getRow(i));

            if (labels.getNumCols() != result.size()) {
                throw new MLException(String.format(
                        "Returned result size [%d] is different than number of columns [%d] in labels!",
                        result.size(), labels.getNumCols()));
            }

            double magnitude = 0;
            for (int j = 0; j < labels.getNumCols(); j++) {

                double actual = labels.getRow(i).get(j);
                double predicted = result.get(j);

                if (labels.isCategorical(j)) {
                    magnitude += MathUtility.isEquals(actual, predicted) ? 0 : 1;
                } else {
                    double res = actual - predicted;
                    magnitude += res * res;
                }
            }
            sum += magnitude;
        }
        return sum;
    }