Package se.hb.jcp.nc
Class ClassifierNonconformityFunctionBase
- java.lang.Object
-
- se.hb.jcp.nc.ClassifierNonconformityFunctionBase
-
- All Implemented Interfaces:
java.io.Serializable,IClassifierInformation,IClassificationNonconformityFunction
- Direct Known Subclasses:
ClassProbabilityNonconformityFunctionBase,kNearestSameClassNeighbourNonconformityFunction,SVMDistanceNonconformityFunction
public abstract class ClassifierNonconformityFunctionBase extends java.lang.Object implements IClassificationNonconformityFunction, java.io.Serializable
Base class for nonconformity functions that use a classifier.- Author:
- anders.gidenstam(at)hb.se
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ClassifierNonconformityFunctionBase(double[] classes, IClassifier classifier)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description double[]calc_nc(cern.colt.matrix.DoubleMatrix2D x, double[] y)Deprecated.double[]calc_nc(cern.colt.matrix.DoubleMatrix2D xtr, double[] ytr, cern.colt.matrix.DoubleMatrix1D xtest, double ytest)abstract doublecalculateNonConformityScore(cern.colt.matrix.DoubleMatrix1D x, double y)Computes the non-conformity score for the instance x with the target y.voidfit(cern.colt.matrix.DoubleMatrix2D x, double[] y)Initializes this non-conformity function with the supplied data.abstract IClassificationNonconformityFunctionfitNew(cern.colt.matrix.DoubleMatrix2D x, double[] y)Returns a new non-conformity function based on the same parameters as the current one initialized with the supplied data.IClassificationNonconformityFunctionfitNew(cern.colt.matrix.DoubleMatrix2D xtr, double[] ytr, cern.colt.matrix.DoubleMatrix1D xtest, double ytest)Returns a new non-conformity function based on the same parameters as the current one initialized with the supplied data.intgetAttributeCount()Returns the number of attributes the classifier has been trained on.IClassifiergetClassifier()Returns the classifier used by this non-conformity function.java.lang.Double[]getLabels()Returns the set of class labels the classifier has been trained on.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.
-
-
-
Constructor Detail
-
ClassifierNonconformityFunctionBase
public ClassifierNonconformityFunctionBase(double[] classes, IClassifier classifier)
-
-
Method Detail
-
fit
public void fit(cern.colt.matrix.DoubleMatrix2D x, double[] y)Description copied from interface:IClassificationNonconformityFunctionInitializes this non-conformity function with the supplied data.- Specified by:
fitin interfaceIClassificationNonconformityFunction- Parameters:
x- the instances.y- the targets/classes/labels of the instances.
-
fitNew
public abstract IClassificationNonconformityFunction fitNew(cern.colt.matrix.DoubleMatrix2D x, double[] y)
Description copied from interface:IClassificationNonconformityFunctionReturns a new non-conformity function based on the same parameters as the current one initialized with the supplied data.- Specified by:
fitNewin interfaceIClassificationNonconformityFunction- Parameters:
x- the instances.y- the targets or classes of the instances.- Returns:
- a new non-conformity function.
-
fitNew
public IClassificationNonconformityFunction fitNew(cern.colt.matrix.DoubleMatrix2D xtr, double[] ytr, cern.colt.matrix.DoubleMatrix1D xtest, double ytest)
Description copied from interface:IClassificationNonconformityFunctionReturns a new non-conformity function based on the same parameters as the current one initialized with the supplied data.- Specified by:
fitNewin interfaceIClassificationNonconformityFunction- Parameters:
xtr- the training instances.ytr- the training targets or classes of the instances.xtest- the test instances.ytest- the test targets/classes/labels of the instances.- Returns:
- a new non-conformity function.
-
calculateNonConformityScore
public abstract double calculateNonConformityScore(cern.colt.matrix.DoubleMatrix1D x, double y)Description copied from interface:IClassificationNonconformityFunctionComputes the non-conformity score for the instance x with the target y.- Specified by:
calculateNonConformityScorein interfaceIClassificationNonconformityFunction- Parameters:
x- the instance.y- the target/class/label.- Returns:
- the non-conformity score. Large means less conforming.
-
calc_nc
@Deprecated public double[] calc_nc(cern.colt.matrix.DoubleMatrix2D x, double[] y)Deprecated.- Specified by:
calc_ncin interfaceIClassificationNonconformityFunction
-
calc_nc
public double[] calc_nc(cern.colt.matrix.DoubleMatrix2D xtr, double[] ytr, cern.colt.matrix.DoubleMatrix1D xtest, double ytest)- Specified by:
calc_ncin interfaceIClassificationNonconformityFunction
-
getClassifier
public IClassifier getClassifier()
Description copied from interface:IClassificationNonconformityFunctionReturns the classifier used by this non-conformity function.- Specified by:
getClassifierin interfaceIClassificationNonconformityFunction- Returns:
- the classifier used by this non-conformity function; or null if there isn't one.
-
isTrained
public final 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 final 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 final 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.
-
-