InputType
- Input type to the Kernelpublic class LocallyWeightedKernelScalarFunction<InputType> extends KernelScalarFunction<InputType>
LocallyWeightedKernelScalarFunction
class implements a scalar
function that uses kernels and does local weighting on them to get the
result value. It also includes the ability to bias the function towards a
constant when the kernel values are very small.Modifier and Type | Field and Description |
---|---|
protected double |
constantValue
The constant value is what the constant weight biases the function
toward when there is near zero weight.
|
protected double |
constantWeight
The constant weight is used as a weight for the constant value that is
added to the result to bias the function to the constant value.
|
static double |
DEFAULT_CONSTANT_VALUE
The default constant value is 0.0.
|
static double |
DEFAULT_CONSTANT_WEIGHT
The default constant weight is 0.0.
|
bias, DEFAULT_BIAS, examples
kernel
Constructor and Description |
---|
LocallyWeightedKernelScalarFunction()
Creates a new instance of LocallyWeightedKernelScalarFunction.
|
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel)
Creates a new instance of LocallyWeightedKernelScalarFunction with the
given kernel.
|
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel,
java.util.Collection<? extends WeightedValue<? extends InputType>> examples)
Creates a new instance of LocallyWeightedKernelScalarFunction with the
given kernel and weighted examples.
|
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel,
java.util.Collection<? extends WeightedValue<? extends InputType>> examples,
double bias)
Creates a new instance of LocallyWeightedKernelScalarFunction with the
given kernel, weighted examples, and bias.
|
LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel,
java.util.Collection<? extends WeightedValue<? extends InputType>> examples,
double bias,
double constantWeight,
double constantValue)
Creates a new instance of LocallyWeightedKernelScalarFunction with the
given kernel, weighted examples, and bias.
|
LocallyWeightedKernelScalarFunction(LocallyWeightedKernelScalarFunction<InputType> other)
Creates a new instance copy of LocallyWeightedKernelScalarFunction.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Double |
evaluate(InputType input)
Categorizes the given input vector as a double by:
(sum w_i * k(input, x_i)) / (sum k(input, x_i))
|
double |
getConstantValue()
Gets the constant value.
|
double |
getConstantWeight()
Gets the constant weight.
|
void |
setConstantValue(double constantValue)
Sets the constant value.
|
void |
setConstantWeight(double constantWeight)
Sets the constant weight.
|
evaluateAsDouble, getBias, getExamples, setBias, setExamples
clone, getKernel, setKernel
public static final double DEFAULT_CONSTANT_WEIGHT
public static final double DEFAULT_CONSTANT_VALUE
protected double constantWeight
protected double constantValue
public LocallyWeightedKernelScalarFunction()
public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel)
kernel
- The kernel to use.public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel, java.util.Collection<? extends WeightedValue<? extends InputType>> examples)
kernel
- The kernel to use.examples
- The weighted examples.public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel, java.util.Collection<? extends WeightedValue<? extends InputType>> examples, double bias)
kernel
- The kernel to use.examples
- The weighted examples.bias
- The bias.public LocallyWeightedKernelScalarFunction(Kernel<? super InputType> kernel, java.util.Collection<? extends WeightedValue<? extends InputType>> examples, double bias, double constantWeight, double constantValue)
kernel
- The kernel to use.examples
- The weighted examples.bias
- The bias.constantWeight
- The constant bias weight to use.constantValue
- The constant bias value to use.public LocallyWeightedKernelScalarFunction(LocallyWeightedKernelScalarFunction<InputType> other)
other
- The object to copy.public java.lang.Double evaluate(InputType input)
evaluate
in interface Evaluator<InputType,java.lang.Double>
evaluate
in interface ScalarFunction<InputType>
evaluate
in class KernelScalarFunction<InputType>
input
- The input to categorize.public double getConstantWeight()
public void setConstantWeight(double constantWeight)
constantWeight
- The constant weight.public double getConstantValue()
public void setConstantValue(double constantValue)
constantValue
- The constant value.