Package elki.similarity.kernel
Class PolynomialKernel
- java.lang.Object
-
- elki.similarity.AbstractVectorSimilarity
-
- elki.similarity.kernel.PolynomialKernel
-
- All Implemented Interfaces:
Distance<NumberVector>
,PrimitiveDistance<NumberVector>
,PrimitiveSimilarity<NumberVector>
,Similarity<NumberVector>
- Direct Known Subclasses:
LinearKernel
public class PolynomialKernel extends AbstractVectorSimilarity implements PrimitiveDistance<NumberVector>
Polynomial Kernel function that computes a similarity between the two feature vectors x and y defined by \((x^T\cdot y+b)^{\text{degree}}\).- Since:
- 0.1
- Author:
- Simon Paradies
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PolynomialKernel.Par
Parameterization class.
-
Field Summary
Fields Modifier and Type Field Description private double
bias
Bias of the similarity function.static int
DEFAULT_DEGREE
The default degree.private int
degree
Degree of the polynomial kernel function.
-
Constructor Summary
Constructors Constructor Description PolynomialKernel(int degree)
Constructor.PolynomialKernel(int degree, double bias)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(NumberVector fv1, NumberVector fv2)
Computes the distance between two given DatabaseObjects according to this distance function.<T extends NumberVector>
DistanceSimilarityQuery<T>instantiate(Relation<T> database)
Instantiate with a database to get the actual distance query.boolean
isMetric()
Is this distance function metric (satisfy the triangle inequality)boolean
isSymmetric()
Is this function symmetric?double
similarity(NumberVector o1, NumberVector o2)
Computes the similarity between two given DatabaseObjects according to this similarity function.-
Methods inherited from class elki.similarity.AbstractVectorSimilarity
getInputTypeRestriction
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.distance.PrimitiveDistance
getInputTypeRestriction
-
-
-
-
Field Detail
-
DEFAULT_DEGREE
public static final int DEFAULT_DEGREE
The default degree.- See Also:
- Constant Field Values
-
degree
private final int degree
Degree of the polynomial kernel function.
-
bias
private final double bias
Bias of the similarity function.
-
-
Method Detail
-
similarity
public double similarity(NumberVector o1, NumberVector o2)
Description copied from interface:PrimitiveSimilarity
Computes the similarity between two given DatabaseObjects according to this similarity function.- Specified by:
similarity
in interfacePrimitiveSimilarity<NumberVector>
- Parameters:
o1
- first DatabaseObjecto2
- second DatabaseObject- Returns:
- the similarity between two given DatabaseObjects according to this similarity function
-
isSymmetric
public boolean isSymmetric()
Description copied from interface:Distance
Is this function symmetric?- Specified by:
isSymmetric
in interfaceDistance<NumberVector>
- Specified by:
isSymmetric
in interfaceSimilarity<NumberVector>
- Returns:
true
when symmetric
-
isMetric
public boolean isMetric()
Description copied from interface:Distance
Is this distance function metric (satisfy the triangle inequality)- Specified by:
isMetric
in interfaceDistance<NumberVector>
- Returns:
true
when metric.
-
distance
public double distance(NumberVector fv1, NumberVector fv2)
Description copied from interface:PrimitiveDistance
Computes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distance
in interfacePrimitiveDistance<NumberVector>
- Parameters:
fv1
- first DatabaseObjectfv2
- second DatabaseObject- Returns:
- the distance between two given DatabaseObjects according to this distance function
-
instantiate
public <T extends NumberVector> DistanceSimilarityQuery<T> instantiate(Relation<T> database)
Description copied from interface:Distance
Instantiate with a database to get the actual distance query.- Specified by:
instantiate
in interfaceDistance<NumberVector>
- Specified by:
instantiate
in interfacePrimitiveDistance<NumberVector>
- Specified by:
instantiate
in interfacePrimitiveSimilarity<NumberVector>
- Specified by:
instantiate
in interfaceSimilarity<NumberVector>
- Parameters:
database
- The representation to use- Returns:
- Actual distance query.
-
-