public class DoubleKNNAssigner extends Object implements SoftAssigner<double[],double[]>
SoftAssigner
that picks a fixed number of nearest neighbours.
Weights returned are actually the distances to the centroids.Modifier and Type | Field and Description |
---|---|
protected DoubleNearestNeighbours |
nn |
protected int |
numNeighbours |
Constructor and Description |
---|
DoubleKNNAssigner(CentroidsProvider<double[]> provider,
boolean exact,
int numNeighbours)
Construct the assigner using the given cluster data.
|
DoubleKNNAssigner(CentroidsProvider<double[]> provider,
DoubleFVComparison comparison,
int numNeighbours)
Construct the assigner using the given cluster data and
distance function.
|
DoubleKNNAssigner(double[][] data,
boolean exact,
int numNeighbours)
Construct the assigner using the given cluster data.
|
DoubleKNNAssigner(double[][] data,
DoubleFVComparison comparison,
int numNeighbours)
Construct the assigner using the given cluster data and
distance function.
|
Modifier and Type | Method and Description |
---|---|
int[] |
assign(double[] data)
Assign a single point to some clusters.
|
int[][] |
assign(double[][] data)
Assign data to clusters.
|
IndependentPair<int[],double[]> |
assignWeighted(double[] data)
Assign a single point to some clusters.
|
void |
assignWeighted(double[][] data,
int[][] assignments,
double[][] weights)
Assign data to clusters.
|
int |
numDimensions()
Get the number of dimensions of the input vectors.
|
int |
size()
The number of clusters.
|
protected DoubleNearestNeighbours nn
protected int numNeighbours
public DoubleKNNAssigner(CentroidsProvider<double[]> provider, boolean exact, int numNeighbours)
DoubleNearestNeighboursExact
or
DoubleNearestNeighboursKDTree
, depending on whether the exact
parameter is true or false. If the parameter is true, then the
resultant DoubleNearestNeighboursExact
will use Euclidean
distance.provider
- the cluster data providerexact
- if true, then use exact mode; false implies approximate mode.numNeighbours
- the number of nearest neighbours to select.public DoubleKNNAssigner(double[][] data, boolean exact, int numNeighbours)
DoubleNearestNeighboursExact
or
DoubleNearestNeighboursKDTree
, depending on whether the exact
parameter is true or false. If the parameter is true, then the
resultant DoubleNearestNeighboursExact
will use Euclidean
distance.data
- the cluster dataexact
- if true, then use exact mode; false implies approximate mode.numNeighbours
- the number of nearest neighbours to select.public DoubleKNNAssigner(CentroidsProvider<double[]> provider, DoubleFVComparison comparison, int numNeighbours)
DoubleNearestNeighboursExact
.provider
- the cluster data providercomparison
- the distance functionnumNeighbours
- the number of nearest neighbours to select.public DoubleKNNAssigner(double[][] data, DoubleFVComparison comparison, int numNeighbours)
DoubleNearestNeighboursExact
.data
- the cluster datacomparison
- the distance functionnumNeighbours
- the number of nearest neighbours to select.public int[][] assign(double[][] data)
SoftAssigner
assign
in interface SoftAssigner<double[],double[]>
data
- the data.public int[] assign(double[] data)
SoftAssigner
assign
in interface SoftAssigner<double[],double[]>
data
- datum to assign.public void assignWeighted(double[][] data, int[][] assignments, double[][] weights)
SoftAssigner
assignWeighted
in interface SoftAssigner<double[],double[]>
data
- the data.assignments
- the cluster indices for each data point.weights
- the weights to the for each cluster for each data point.public IndependentPair<int[],double[]> assignWeighted(double[] data)
SoftAssigner
assignWeighted
in interface SoftAssigner<double[],double[]>
data
- point to assign.public int numDimensions()
Assigner
numDimensions
in interface Assigner<double[]>
public int size()
SoftAssigner
size
in interface SoftAssigner<double[],double[]>