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