Click or drag to resize
Accord.NET (logo)

KernelDiscriminantAnalysis Class

Kernel (Fisher) Discriminant Analysis.
Inheritance Hierarchy
SystemObject
  Accord.MachineLearningTransformBaseDouble, Double
    Accord.Statistics.AnalysisBaseDiscriminantAnalysis
      Accord.Statistics.AnalysisKernelDiscriminantAnalysis

Namespace:  Accord.Statistics.Analysis
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class KernelDiscriminantAnalysis : BaseDiscriminantAnalysis, 
	ISupervisedLearning<KernelDiscriminantAnalysisPipeline, double[], int>
Request Example View Source

The KernelDiscriminantAnalysis type exposes the following members.

Constructors
Properties
  NameDescription
Protected propertyClassCount
Gets the observation count for each class.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyClasses
Gets information about the distinct classes in the analyzed data.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyClassifications Obsolete.
Gets the original classifications (labels) of the source data given on the moment of creation of this analysis object.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyClassifier
Protected propertyClassMeans
Gets the Mean vector for each class.
(Inherited from BaseDiscriminantAnalysis.)
Protected propertyClassScatter
Gets the Scatter matrix for each class.
(Inherited from BaseDiscriminantAnalysis.)
Protected propertyClassStandardDeviations
Gets the Standard Deviation vector for each class.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyCumulativeProportions
The cumulative distribution of the discriminants factors proportions. Also known as the cumulative energy of the first dimensions of the discriminant space or as the amount of variance explained by those dimensions.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyDiscriminantMatrix Obsolete.
Gets the Eigenvectors obtained during the analysis, composing a basis for the discriminant factor space.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyDiscriminantProportions
Gets the level of importance each discriminant factor has in discriminant space. Also known as amount of variance explained.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyDiscriminants
Gets the discriminant factors in a object-oriented fashion.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyDiscriminantVectors
Gets the Eigenvectors obtained during the analysis, composing a basis for the discriminant factor space.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyEigenvalues
Gets the Eigenvalues found by the analysis associated with each vector of the ComponentMatrix matrix.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyInput
Gets or sets the matrix of original values used to create this analysis. Those values are required to build kernel (Gram) matrices when classifying new samples.
Public propertyKernel
Gets or sets the Kernel used in the analysis.
Public propertyMeans
Gets the mean of the original data given at method construction.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyNumberOfClasses
Gets the number of classes in the analysis.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyNumberOfInputs
Gets the number of inputs accepted by the model.
(Inherited from TransformBaseTInput, TOutput.)
Public propertyNumberOfOutputs
Gets the number of outputs generated by the model.
(Inherited from TransformBaseTInput, TOutput.)
Public propertyNumberOfSamples
Gets the number of samples used to create the analysis.
(Inherited from BaseDiscriminantAnalysis.)
Protected propertyProjectionMeans
Gets the feature space mean of the projected data.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyRegularization
Gets or sets the regularization parameter to avoid non-singularities at the solution.
Public propertyResult Obsolete.
Gets the resulting projection of the source data given on the creation of the analysis into discriminant space.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyScatterBetweenClass
Gets the Between-Class Scatter Matrix for the data.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyScatterMatrix
Gets the Total Scatter Matrix for the data.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyScatterWithinClass
Gets the Within-Class Scatter Matrix for the data.
(Inherited from BaseDiscriminantAnalysis.)
Public propertySource Obsolete.
Returns the original supplied data to be analyzed.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyStandardDeviations
Gets the standard mean of the original data given at method construction.
(Inherited from BaseDiscriminantAnalysis.)
Public propertyThreshold
Gets or sets the minimum variance proportion needed to keep a discriminant component. If set to zero, all components will be kept. Default is 0.001 (all components which contribute less than 0.001 to the variance in the data will be discarded).
(Inherited from BaseDiscriminantAnalysis.)
Public propertyToken
Gets or sets a cancellation token that can be used to stop the learning algorithm while it is running.
(Inherited from BaseDiscriminantAnalysis.)
Top
Methods
  NameDescription
Public methodClassify(Double) Obsolete.
Classifies a new instance into one of the available classes.
(Overrides BaseDiscriminantAnalysisClassify(Double).)
Public methodClassify(Double) Obsolete.
Classifies new instances into one of the available classes.
(Overrides BaseDiscriminantAnalysisClassify(Double).)
Public methodClassify(Double, Double) Obsolete.
Classifies a new instance into one of the available classes.
(Overrides BaseDiscriminantAnalysisClassify(Double, Double).)
Public methodCompute Obsolete.
Computes the Multi-Class Kernel Discriminant Analysis algorithm.
Protected methodCreateDiscriminants
Creates additional information about principal components.
(Inherited from BaseDiscriminantAnalysis.)
Public methodDiscriminantFunction
Gets the output of the discriminant function for a given class.
(Overrides BaseDiscriminantAnalysisDiscriminantFunction(Double, Int32).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetNumberOfDimensions
Returns the minimum number of discriminant space dimensions (discriminant factors) required to represent a given percentile of the data.
(Inherited from BaseDiscriminantAnalysis.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodinit Obsolete.
Obsolete.
(Inherited from BaseDiscriminantAnalysis.)
Protected methodInit
Initializes common properties.
(Inherited from BaseDiscriminantAnalysis.)
Public methodLearn
Learns a model that can map the given inputs to the given outputs.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTransform(Double) Obsolete.
Obsolete.
(Inherited from BaseDiscriminantAnalysis.)
Public methodTransform(Double)
Applies the transformation to an input, producing an associated output.
(Inherited from BaseDiscriminantAnalysis.)
Public methodTransform(Double)
Applies the transformation to an input, producing an associated output.
(Inherited from BaseDiscriminantAnalysis.)
Public methodTransform(Double, Int32) Obsolete.
Obsolete.
(Inherited from BaseDiscriminantAnalysis.)
Public methodTransform(Double, Int32) Obsolete.
Obsolete.
(Inherited from BaseDiscriminantAnalysis.)
Public methodTransform(Double, Int32) Obsolete.
Obsolete.
(Inherited from BaseDiscriminantAnalysis.)
Public methodTransform(Double, Double)
Applies the transformation to an input, producing an associated output.
(Overrides TransformBaseTInput, TOutputTransform(TInput, TOutput).)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

Kernel (Fisher) discriminant analysis (kernel FDA) is a non-linear generalization of linear discriminant analysis (LDA) using techniques of kernel methods. Using a kernel, the originally linear operations of LDA are done in a reproducing kernel Hilbert space with a non-linear mapping.

The algorithm used is a multi-class generalization of the original algorithm by Mika et al. in Fisher discriminant analysis with kernels (1999).

This class can also be bound to standard controls such as the DataGridView by setting their DataSource property to the analysis' Discriminants property.

References:

Examples
// Create some sample input data instances. This is the same
// data used in the Gutierrez-Osuna's example available on:
// http://research.cs.tamu.edu/prism/lectures/pr/pr_l10.pdf

double[][] inputs = 
{
    // Class 0
    new double[] {  4,  1 }, 
    new double[] {  2,  4 },
    new double[] {  2,  3 },
    new double[] {  3,  6 },
    new double[] {  4,  4 },

    // Class 1
    new double[] {  9, 10 },
    new double[] {  6,  8 },
    new double[] {  9,  5 },
    new double[] {  8,  7 },
    new double[] { 10,  8 }
};

int[] output = 
{
    0, 0, 0, 0, 0, // The first five are from class 0
    1, 1, 1, 1, 1  // The last five are from class 1
};


// We'll create a KDA using a Linear kernel
var kda = new KernelDiscriminantAnalysis()
{
    Kernel = new Linear() // We can choose any kernel function
};

// Compute the analysis and create a classifier
var classifier = kda.Learn(inputs, output); 

// Now we can project the data into KDA space:
double[][] projection = kda.Transform(inputs);

// Or perform classification using:
int[] results = kda.Classify(inputs);
See Also