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