Package org.biojava.stats.svm
Class SparseVector.NormalizingKernel
- java.lang.Object
-
- org.biojava.stats.svm.SparseVector.NormalizingKernel
-
- All Implemented Interfaces:
java.io.Serializable,SVMKernel
- Enclosing class:
- SparseVector
public static class SparseVector.NormalizingKernel extends java.lang.Object implements SVMKernel, java.io.Serializable
A version of the standard dot-product kernel that scales each column independently.- Author:
- Matthew Pocock
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NormalizingKernel(java.util.List vectors)Generate a normalizing kernel defined by the SparseVectors in vectors.NormalizingKernel(SparseVector s)Generate a normalizing kernel with the normalizing vector s.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleevaluate(java.lang.Object o1, java.lang.Object o2)Evaluate the kernel function between two SparseVectors.SparseVectorgetNormalizingVector()Retrive the current normalizing vector.voidsetNormalizingVector(SparseVector nv)Set the normalizing vector.java.lang.StringtoString()
-
-
-
Constructor Detail
-
NormalizingKernel
public NormalizingKernel(SparseVector s)
Generate a normalizing kernel with the normalizing vector s.- Parameters:
s- the SparseVector to normalize by
-
NormalizingKernel
public NormalizingKernel(java.util.List vectors)
Generate a normalizing kernel defined by the SparseVectors in vectors.It will set up a normalizing vector that has weight that will scale each element so that the average score is 1.
-
-
Method Detail
-
getNormalizingVector
public SparseVector getNormalizingVector()
Retrive the current normalizing vector.- Returns:
- the normalizing vector
-
setNormalizingVector
public void setNormalizingVector(SparseVector nv)
Set the normalizing vector.- Parameters:
nv- the new normalizing vector
-
evaluate
public double evaluate(java.lang.Object o1, java.lang.Object o2)Evaluate the kernel function between two SparseVectors.This function is equivalent to:
k(a, b) = sum_i ( a_i * b_i * nv_i )
where nv_i is the value of the normalizing vector at index i. This can be thought of as scaling each vector at index i bysqrt(nv_i).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-