Package se.hb.jcp.cp
Class TransductiveConformalClassifier
- java.lang.Object
-
- se.hb.jcp.cp.TransductiveConformalClassifier
-
- All Implemented Interfaces:
java.io.Serializable,IConformalClassifier,IClassifierInformation
public class TransductiveConformalClassifier extends java.lang.Object implements IConformalClassifier, java.io.Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TransductiveConformalClassifier(IClassificationNonconformityFunction nc, double[] targets)Creates a transductive conformal classifier using the supplied information.TransductiveConformalClassifier(IClassificationNonconformityFunction nc, double[] targets, boolean useLabelConditionalCP)Creates a transductive conformal classifier using the supplied information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfit(cern.colt.matrix.DoubleMatrix2D xtr, double[] ytr)Trains this conformal classifier using the supplied data.intgetAttributeCount()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.IClassificationNonconformityFunctiongetNonconformityFunction()Returns the associated nonconformity function.booleanisTrained()Returns whether this classifier has been trained.cern.colt.matrix.DoubleMatrix1DnativeStorageTemplate()Returns a value of the DoubleMatrix1D derived class that is the native storage format for the classifier.ConformalClassificationpredict(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.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.voidsetNonconformityFunction(IClassificationNonconformityFunction nc)Sets a new non-conformity function in this transductive conformal classifier.
-
-
-
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:
predictin interfaceIConformalClassifier- 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:
predictin interfaceIConformalClassifier- 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:
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)
Computes 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)Computes 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.
-
getNonconformityFunction
public IClassificationNonconformityFunction getNonconformityFunction()
Description copied from interface:IConformalClassifierReturns the associated nonconformity function.- Specified by:
getNonconformityFunctionin interfaceIConformalClassifier- Returns:
- the associated IClassificationNonconformityFunction.
-
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:IClassifierInformationReturns whether this classifier has been trained.- Specified by:
isTrainedin interfaceIClassifierInformation- Returns:
- Returns true if the classifier has been trained 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.
-
-