Package se.hb.jcp.cp

Class TransductiveConformalClassifier

    • Constructor Detail

      • TransductiveConformalClassifier

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

        public TransductiveConformalClassifier​(IClassificationNonconformityFunction nc,
                                               double[] targets,
                                               boolean useLabelConditionalCP)
        Creates a transductive 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)
        Trains this conformal classifier using the supplied data.
        Parameters:
        xtr - the attributes of the training instances.
        ytr - the targets of the training 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 transductive conformal classifier. The new non-conformity function will be used for all future predictions.
        Parameters:
        nc - the new non-conformity function.
      • isTrained

        public boolean isTrained()
        Description copied from interface: IClassifierInformation
        Returns whether this classifier has been trained.
        Specified by:
        isTrained in interface IClassifierInformation
        Returns:
        Returns true if the classifier has been trained 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.