Click or drag to resize
Accord.NET (logo)

Wavelet Structure

Wavelet Kernel.

Namespace:  Accord.Statistics.Kernels
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public struct Wavelet : IKernel, IKernel<double[]>, 
	ICloneable, IKernel<int[]>, IDistance, IDistance<double[]>, 
	IDistance<double[], double[]>, IDistance<int[]>, 
	IDistance<int[], int[]>
Request Example View Source

The Wavelet type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyDilation
Gets or sets the wavelet dilation for this kernel.
Public propertyInvariant
Gets or sets whether this is an invariant Wavelet kernel.
Public propertyMother
Gets or sets the Mother wavelet for this kernel.
Public propertyTranslation
Gets or sets the wavelet translation for this kernel.
Top
Methods
  NameDescription
Public methodClone
Creates a new object that is a copy of the current instance.
Public methodDistance(Double, Double)
Computes the squared distance in feature space between two points given in input space.
Public methodDistance(Int32, Int32)
Computes the squared distance in feature space between two points given in input space.
Public methodEquals
Indicates whether this instance and a specified object are equal.
(Inherited from ValueType.)
Public methodFunction(Double, Double)
Wavelet kernel function.
Public methodFunction(Int32, Int32)
Wavelet kernel function.
Public methodGetHashCode
Returns the hash code for this instance.
(Inherited from ValueType.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns the fully qualified type name of this instance.
(Inherited from ValueType.)
Top
Extension Methods
  NameDescription
Public Extension MethodDistance
Computes the kernel distance for a kernel function even if it doesn't implement the IDistance interface. Can be used to check the proper implementation of the distance function.
(Defined by Tools.)
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

In Wavelet analysis theory, one of the common goals is to express or approximate a signal or function using a family of functions generated by dilations and translations of a function called the mother wavelet.

The Wavelet kernel uses a mother wavelet function together with dilation and translation constants to produce such representations and build a inner product which can be used by kernel methods. The default wavelet used by this class is the mother function h(x) = cos(1.75x)*exp(-x²/2).

References:

  • Li Zhang, Weida Zhou, and Licheng Jiao; Wavelet Support Vector Machine. IEEE Transactions on Systems, Man, and Cybernetics—Part B: Cybernetics, Vol. 34, No. 1, February 2004.

Examples
// Generate always same random numbers
Accord.Math.Random.Generator.Seed = 0;

// The following is a simple auto association function in which 
// the last column of each input correspond to its own class. This
// problem should be easily solved using a Linear kernel.

// Sample input data
int[][] inputs =
{
    new int[] { 1, 2, 0 },
    new int[] { 6, 2, 3 },
    new int[] { 1, 1, 1 },
    new int[] { 7, 6, 2 },
};

// Output for each of the inputs
int[] outputs = { 0, 3, 1, 2 };

// Create the multi-class learning algorithm for the machine
var teacher = new MulticlassSupportVectorLearning<Wavelet, int[]>()
{
    // Configure the learning algorithm to use SMO to train the
    //  underlying SVMs in each of the binary class subproblems.
    Learner = (param) => new SequentialMinimalOptimization<Wavelet, int[]>()
    {
        // If you would like to use other kernels, simply replace
        // the generic parameter to the desired kernel class, such
        // as for example, Wavelet:

        Kernel = new Wavelet(invariant: true) // use the Wavelet kernel
    }
};

// You can set extra properties to configure the learning if you would like:
teacher.AggregateExceptions = true;
teacher.ParallelOptions.MaxDegreeOfParallelism = 1;

// Estimate the multi-class support vector machine using one-vs-one method
var ovo = teacher.Learn(inputs, outputs);

// Obtain class predictions for each sample
int[] predicted = ovo.Decide(inputs);

// Compute classification error
double error = new ZeroOneLoss(outputs).Loss(predicted);
See Also