Package se.hb.jcp.cp
Class ConformalMultiProbabilisticClassifier
- java.lang.Object
-
- se.hb.jcp.cp.ConformalMultiProbabilisticClassifier
-
- All Implemented Interfaces:
java.io.Serializable,IConformalClassifier,IClassifierInformation
public class ConformalMultiProbabilisticClassifier extends java.lang.Object implements IConformalClassifier, java.io.Serializable
Represents a multi-probabilistic conformal classifier with bivariate isotonic regression. See [C. Zhou, "Conformal and Venn Predictors for Multi-probabilistic Predictions and Their Applications", Ph.D. Thesis, Department of Computer Science, Royal Holloway, University of London, 2015] for the details. NOTE: The description in the Thesis above is not completely clear so the implementation here is partially done by educated guesses. Updated proofs of the desired properties remain to be done.- Author:
- anders.gidenstam(at)hb.se
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ConformalMultiProbabilisticClassifier(IConformalClassifier classifier)Creates a multi-probabilistic conformal classifier with bivariate isotonic regression using the supplied information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalibrate(cern.colt.matrix.DoubleMatrix2D xcal, double[] ycal)Calibrates this multi-probabilistic conformal classifier using the supplied data.intgetAttributeCount()Returns the number of attributes the classifier has been trained on.IConformalClassifiergetConformalClassifier()Returns the underlying conformal classifier.java.lang.Double[]getLabels()Returns the set of class labels the classifier has been trained on.IClassificationNonconformityFunctiongetNonconformityFunction()Returns the associated nonconformity function.booleanisTrained()Returns whether this classifier has been trained and calibrated.cern.colt.matrix.DoubleMatrix1DnativeStorageTemplate()Returns a value of the DoubleMatrix1D derived class that is the native storage format for the classifier.ConformalMultiProbabilisticClassificationpredict(cern.colt.matrix.DoubleMatrix1D x)Makes a prediction for the instance x.ConformalMultiProbabilisticClassification[]predict(cern.colt.matrix.DoubleMatrix2D x)Makes a prediction for each instance in x.cern.colt.matrix.DoubleMatrix1DpredictPValues(cern.colt.matrix.DoubleMatrix1D x)Computes the predicted p-values for the instance x.voidpredictPValues(cern.colt.matrix.DoubleMatrix1D x, cern.colt.matrix.DoubleMatrix1D pValues)Computes the predicted p-values for the instance x.cern.colt.matrix.DoubleMatrix2DpredictPValues(cern.colt.matrix.DoubleMatrix2D x)Computes the predicted p-values for each target and instance in x.
-
-
-
Constructor Detail
-
ConformalMultiProbabilisticClassifier
public ConformalMultiProbabilisticClassifier(IConformalClassifier classifier)
Creates a multi-probabilistic conformal classifier with bivariate isotonic regression using the supplied information.- Parameters:
classifier- the trained conformal classifier to use.
-
-
Method Detail
-
calibrate
public void calibrate(cern.colt.matrix.DoubleMatrix2D xcal, double[] ycal)Calibrates this multi-probabilistic conformal classifier using the supplied data.- Parameters:
xcal- the attributes of the calibration instances.ycal- the targets of the calibration instances.
-
predict
public ConformalMultiProbabilisticClassification[] predict(cern.colt.matrix.DoubleMatrix2D x)
Makes a prediction for each instance in x. The method is parallellized over the instances.- Specified by:
predictin interfaceIConformalClassifier- Parameters:
x- the instances.- Returns:
- an array containing a ConformalMultiProbabilisticClassification for each instance.
-
predict
public ConformalMultiProbabilisticClassification predict(cern.colt.matrix.DoubleMatrix1D x)
Makes a prediction for the instance x.- Specified by:
predictin interfaceIConformalClassifier- Parameters:
x- the instance.- Returns:
- a prediction in the form of a ConformalMultiProbabilisticClassification.
-
predictPValues
public cern.colt.matrix.DoubleMatrix2D predictPValues(cern.colt.matrix.DoubleMatrix2D x)
Description copied from interface:IConformalClassifierComputes the predicted p-values for each target and instance in x. The method is parallellized over the instances.- Specified by:
predictPValuesin interfaceIConformalClassifier- 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)
Description copied from interface:IConformalClassifierComputes the predicted p-values for the instance x.- Specified by:
predictPValuesin interfaceIConformalClassifier- 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)Description copied from interface:IConformalClassifierComputes the predicted p-values for the instance x.- Specified by:
predictPValuesin interfaceIConformalClassifier- Parameters:
x- the instance.pValues- an initialized DoubleMatrix1D to store the p-values.
-
getConformalClassifier
public IConformalClassifier getConformalClassifier()
Returns the underlying conformal classifier.- Returns:
- the underlying conformal classifier.
-
getNonconformityFunction
public IClassificationNonconformityFunction getNonconformityFunction()
Description copied from interface:IConformalClassifierReturns the associated nonconformity function.- Specified by:
getNonconformityFunctionin interfaceIConformalClassifier- Returns:
- the associated IClassificationNonconformityFunction.
-
isTrained
public boolean isTrained()
Returns whether this classifier has been trained and calibrated.- Specified by:
isTrainedin interfaceIClassifierInformation- Returns:
- true if the classifier has been trained and calibrated or false otherwise.
-
getAttributeCount
public int getAttributeCount()
Description copied from interface:IClassifierInformationReturns the number of attributes the classifier has been trained on.- Specified by:
getAttributeCountin interfaceIClassifierInformation- 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:IClassifierInformationReturns the set of class labels the classifier has been trained on.- Specified by:
getLabelsin interfaceIClassifierInformation- 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:IClassifierInformationReturns a value of the DoubleMatrix1D derived class that is the native storage format for the classifier.- Specified by:
nativeStorageTemplatein interfaceIClassifierInformation- Returns:
- a value of the DoubleMatrix1D derived class of the native storage format for the classifier.
-
-