public class LongKNNAssigner extends Object implements SoftAssigner<long[],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 LongNearestNeighbours |
nn |
protected int |
numNeighbours |
Constructor and Description |
---|
LongKNNAssigner(CentroidsProvider<long[]> provider,
boolean exact,
int numNeighbours)
Construct the assigner using the given cluster data.
|
LongKNNAssigner(CentroidsProvider<long[]> provider,
LongFVComparison comparison,
int numNeighbours)
Construct the assigner using the given cluster data and
distance function.
|
LongKNNAssigner(long[][] data,
boolean exact,
int numNeighbours)
Construct the assigner using the given cluster data.
|
LongKNNAssigner(long[][] data,
LongFVComparison comparison,
int numNeighbours)
Construct the assigner using the given cluster data and
distance function.
|
Modifier and Type | Method and Description |
---|---|
int[] |
assign(long[] data)
Assign a single point to some clusters.
|
int[][] |
assign(long[][] data)
Assign data to clusters.
|
IndependentPair<int[],double[]> |
assignWeighted(long[] data)
Assign a single point to some clusters.
|
void |
assignWeighted(long[][] 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 LongNearestNeighbours nn
protected int numNeighbours
public LongKNNAssigner(CentroidsProvider<long[]> provider, boolean exact, int numNeighbours)
LongNearestNeighboursExact
or
LongNearestNeighboursKDTree
, depending on whether the exact
parameter is true or false. If the parameter is true, then the
resultant LongNearestNeighboursExact
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 LongKNNAssigner(long[][] data, boolean exact, int numNeighbours)
LongNearestNeighboursExact
or
LongNearestNeighboursKDTree
, depending on whether the exact
parameter is true or false. If the parameter is true, then the
resultant LongNearestNeighboursExact
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 LongKNNAssigner(CentroidsProvider<long[]> provider, LongFVComparison comparison, int numNeighbours)
LongNearestNeighboursExact
.provider
- the cluster data providercomparison
- the distance functionnumNeighbours
- the number of nearest neighbours to select.public LongKNNAssigner(long[][] data, LongFVComparison comparison, int numNeighbours)
LongNearestNeighboursExact
.data
- the cluster datacomparison
- the distance functionnumNeighbours
- the number of nearest neighbours to select.public int[][] assign(long[][] data)
SoftAssigner
assign
in interface SoftAssigner<long[],double[]>
data
- the data.public int[] assign(long[] data)
SoftAssigner
assign
in interface SoftAssigner<long[],double[]>
data
- datum to assign.public void assignWeighted(long[][] data, int[][] assignments, double[][] weights)
SoftAssigner
assignWeighted
in interface SoftAssigner<long[],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(long[] data)
SoftAssigner
assignWeighted
in interface SoftAssigner<long[],double[]>
data
- point to assign.public int numDimensions()
Assigner
numDimensions
in interface Assigner<long[]>
public int size()
SoftAssigner
size
in interface SoftAssigner<long[],double[]>