@Override public double estimate(Vector example, Object label) { Objects.requireNonNull(example, "Require an example."); int trueClassIndex = classifier.getClasses().loc().indexOf(label); Check.argument(trueClassIndex >= 0, "illegal label %s", label); return errorFunction.apply(classifier.estimate(example), trueClassIndex); }
@Override public DoubleArray estimate(DataFrame x, Vector y) { Objects.requireNonNull(x, "Input data required."); Objects.requireNonNull(y, "Input target required."); Check.argument(x.rows() == y.size(), "The size of input data and input target don't match."); return errorFunction.apply(classifier.estimate(x), y, classifier.getClasses()); }
@Override public InductiveConformalClassifier fit(DataFrame x, Vector y) { Objects.requireNonNull(x, "Input data is required."); Objects.requireNonNull(y, "Input target is required."); Check.argument(x.rows() == y.size(), "The size of input data and input target don't match."); return new InductiveConformalClassifier(learner.fit(x, y), Vectors.unique(y)); }
@Override public Nonconformity fit(DataFrame x, Vector y) { Objects.requireNonNull(x, "Input data is required."); Objects.requireNonNull(y, "Input target is required."); Check.argument(x.rows() == y.size(), "The size of input data and input target don't match"); Classifier probabilityEstimator = classifier.fit(x, y); Check.state( probabilityEstimator != null && probabilityEstimator .getCharacteristics() .contains(ClassifierCharacteristic.ESTIMATOR), "The produced classifier can't estimate probabilities"); return new ProbabilityEstimateNonconformity(probabilityEstimator, errorFunction); }