Package se.hb.jcp.cp

Class InductiveConformalClassifier

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void calibrate​(cern.colt.matrix.DoubleMatrix2D xcal, double[] ycal)
      Calibrates this conformal classifier using the supplied data.
      void fit​(cern.colt.matrix.DoubleMatrix2D xtr, double[] ytr, cern.colt.matrix.DoubleMatrix2D xcal, double[] ycal)
      Trains and calibrates this conformal classifier using the supplied data.
      int getAttributeCount()
      Returns the number of attributes the classifier has been trained on.
      java.lang.Double[] getLabels()
      Returns the set of class labels the classifier has been trained on.
      IClassificationNonconformityFunction getNonconformityFunction()
      Returns the associated nonconformity function.
      boolean isTrained()
      Returns whether this classifier has been trained and calibrated.
      cern.colt.matrix.DoubleMatrix1D nativeStorageTemplate()
      Returns a value of the DoubleMatrix1D derived class that is the native storage format for the classifier.
      ConformalClassification predict​(cern.colt.matrix.DoubleMatrix1D x)
      Makes a prediction for the instance x.
      ConformalClassification[] predict​(cern.colt.matrix.DoubleMatrix2D x)
      Makes a prediction for each instance in x.
      cern.colt.matrix.DoubleMatrix1D predictPValues​(cern.colt.matrix.DoubleMatrix1D x)
      Computes the predicted p-values for the instance x.
      void predictPValues​(cern.colt.matrix.DoubleMatrix1D x, cern.colt.matrix.DoubleMatrix1D pValues)
      Computes the predicted p-values for the instance x.
      cern.colt.matrix.DoubleMatrix2D predictPValues​(cern.colt.matrix.DoubleMatrix2D x)
      Computes the predicted p-values for each target and instance in x.
      void setNonconformityFunction​(IClassificationNonconformityFunction nc)
      Sets a new non-conformity function in this inductive conformal classifier.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InductiveConformalClassifier

        public InductiveConformalClassifier​(IClassificationNonconformityFunction nc,
                                            double[] targets)
        Creates an inductive conformal classifier using the supplied information.
        Parameters:
        nc - the untrained non-conformity function to use.
        targets - the class labels.
      • InductiveConformalClassifier

        public InductiveConformalClassifier​(IClassificationNonconformityFunction nc,
                                            double[] targets,
                                            boolean useLabelConditionalCP)
        Creates an inductive conformal classifier using the supplied information.
        Parameters:
        nc - the untrained non-conformity function to use.
        targets - the class labels.
        useLabelConditionalCP - a boolean indicating whether label conditional conformal prediction should be used.
    • Method Detail

      • fit

        public void fit​(cern.colt.matrix.DoubleMatrix2D xtr,
                        double[] ytr,
                        cern.colt.matrix.DoubleMatrix2D xcal,
                        double[] ycal)
        Trains and calibrates this conformal classifier using the supplied data.
        Parameters:
        xtr - the attributes of the training instances.
        ytr - the targets of the training instances.
        xcal - the attributes of the calibration instances.
        ycal - the targets of the calibration instances.
      • calibrate

        public void calibrate​(cern.colt.matrix.DoubleMatrix2D xcal,
                              double[] ycal)
        Calibrates this conformal classifier using the supplied data. The classifier's non-conformity function must have been trained first.
        Parameters:
        xcal - the attributes of the calibration instances.
        ycal - the targets of the calibration instances.
      • predict

        public ConformalClassification[] predict​(cern.colt.matrix.DoubleMatrix2D x)
        Makes a prediction for each instance in x. The method is parallellized over the instances.
        Specified by:
        predict in interface IConformalClassifier
        Parameters:
        x - the instances.
        Returns:
        an array containing a ConformalClassification for each instance.
      • predict

        public ConformalClassification predict​(cern.colt.matrix.DoubleMatrix1D x)
        Makes a prediction for the instance x.
        Specified by:
        predict in interface IConformalClassifier
        Parameters:
        x - the instance.
        Returns:
        a prediction in the form of a ConformalClassification.
      • predictPValues

        public cern.colt.matrix.DoubleMatrix2D predictPValues​(cern.colt.matrix.DoubleMatrix2D x)
        Computes the predicted p-values for each target and instance in x. The method is parallellized over the instances.
        Specified by:
        predictPValues in interface IConformalClassifier
        Parameters:
        x - the instances.
        Returns:
        an DoubleMatrix2D containing the predicted p-values for each instance.
      • predictPValues

        public cern.colt.matrix.DoubleMatrix1D predictPValues​(cern.colt.matrix.DoubleMatrix1D x)
        Computes the predicted p-values for the instance x.
        Specified by:
        predictPValues in interface IConformalClassifier
        Parameters:
        x - the instance.
        Returns:
        an DoubleMatrix1D containing the predicted p-values.
      • predictPValues

        public void predictPValues​(cern.colt.matrix.DoubleMatrix1D x,
                                   cern.colt.matrix.DoubleMatrix1D pValues)
        Computes the predicted p-values for the instance x.
        Specified by:
        predictPValues in interface IConformalClassifier
        Parameters:
        x - the instance.
        pValues - an initialized DoubleMatrix1D to store the p-values.
      • setNonconformityFunction

        public void setNonconformityFunction​(IClassificationNonconformityFunction nc)
        Sets a new non-conformity function in this inductive conformal classifier. The conformal classifier must be (re)calibrated before the new non-conformity function can be used for predictions.
        Parameters:
        nc - the new non-conformity function.
      • isTrained

        public boolean isTrained()
        Returns whether this classifier has been trained and calibrated.
        Specified by:
        isTrained in interface IClassifierInformation
        Returns:
        true if the classifier has been trained and calibrated or false otherwise.
      • getAttributeCount

        public int getAttributeCount()
        Description copied from interface: IClassifierInformation
        Returns the number of attributes the classifier has been trained on.
        Specified by:
        getAttributeCount in interface IClassifierInformation
        Returns:
        Returns the number of attributes the classifier has been trained on or -1 if the classifier has not been trained.
      • getLabels

        public java.lang.Double[] getLabels()
        Description copied from interface: IClassifierInformation
        Returns the set of class labels the classifier has been trained on.
        Specified by:
        getLabels in interface IClassifierInformation
        Returns:
        Returns the class labels the classifier has been trained on in increasing order (the index is the class id) or null if the classifier has not been trained.
      • nativeStorageTemplate

        public cern.colt.matrix.DoubleMatrix1D nativeStorageTemplate()
        Description copied from interface: IClassifierInformation
        Returns a value of the DoubleMatrix1D derived class that is the native storage format for the classifier.
        Specified by:
        nativeStorageTemplate in interface IClassifierInformation
        Returns:
        a value of the DoubleMatrix1D derived class of the native storage format for the classifier.