public class DANN extends Object implements Classifier, Parameterized
NearestNeighbour
classifier. The
localized metric is similar to the MahalanobisDistance
VectorCollectionFactory
allowed in the constructor is to accelerate
the first convergence step. In homogeneous areas of the data set, queries can
be answered in O(log n) if the vector collection supports it.
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_EPS
The default regularization used when building a metric is
1.0
|
static int |
DEFAULT_ITERATIONS
The default number of iterations for creating the metric is
1
|
static int |
DEFAULT_K
The default number of neighbors to use when classifying is
1
|
static int |
DEFAULT_KN
The default number of neighbors to use when building a metric is
40.
|
Constructor and Description |
---|
DANN()
Creates a new DANN classifier
|
DANN(int kn,
int k)
Creates a new DANN classifier
|
DANN(int kn,
int k,
double eps)
Creates a new DANN classifier
|
DANN(int kn,
int k,
double eps,
int maxIterations,
VectorCollectionFactory<VecPaired<Vec,Integer>> vcf)
Creates a new DANN classifier
|
DANN(int kn,
int k,
double eps,
VectorCollectionFactory<VecPaired<Vec,Integer>> vcf)
Creates a new DANN classifier
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
Classifier |
clone() |
double |
getEpsilon()
Returns the regularization parameter that is applied to the diagonal of
the matrix when creating each new metric.
|
int |
getK()
Returns the number of nearest neighbors to use when predicting
|
int |
getKn()
Returns the number of nearest neighbors to use when adapting the distance
metric
|
int |
getMaxIterations()
Returns the number of times the distance metric will be updated.
|
Parameter |
getParameter(String paramName)
Returns the parameter with the given name.
|
List<Parameter> |
getParameters()
Returns the list of parameters that can be altered for this learner.
|
static Distribution |
guessK(DataSet d)
Guesses the distribution to use for the number of neighbors to consider
|
static Distribution |
guessKn(DataSet d)
Guesses the distribution to use for the number of neighbors to consider
|
void |
setEpsilon(double eps)
Sets the regularization to apply the the diagonal of the scatter matrix
when creating each new metric.
|
void |
setK(int k)
Sets the number of nearest neighbors to use when predicting
|
void |
setKn(int kn)
Sets the number of nearest neighbors to use when adapting the distance
metric.
|
void |
setMaxIterations(int maxIterations)
Sets the number of times a new distance metric will be created for each
query.
|
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
void |
trainC(ClassificationDataSet dataSet)
Trains the classifier and constructs a model for classification using the
given data set.
|
void |
trainC(ClassificationDataSet dataSet,
ExecutorService threadPool)
Trains the classifier and constructs a model for classification using the
given data set.
|
public static final int DEFAULT_KN
public static final int DEFAULT_K
public static final double DEFAULT_EPS
public static final int DEFAULT_ITERATIONS
public DANN()
public DANN(int kn, int k)
kn
- the number of neighbors to use in casting a net to build a new metrick
- the number of neighbors to use with the final metric in classificationpublic DANN(int kn, int k, double eps)
kn
- the number of neighbors to use in casting a net to build a new metrick
- the number of neighbors to use with the final metric in classificationeps
- the regularization to add to the metric creationpublic DANN(int kn, int k, double eps, VectorCollectionFactory<VecPaired<Vec,Integer>> vcf)
kn
- the number of neighbors to use in casting a net to build a new metrick
- the number of neighbors to use with the final metric in classificationeps
- the regularization to add to the metric creationvcf
- the default vector collection that will be used for initial
neighbor searchpublic DANN(int kn, int k, double eps, int maxIterations, VectorCollectionFactory<VecPaired<Vec,Integer>> vcf)
kn
- the number of neighbors to use in casting a net to build a new metrick
- the number of neighbors to use with the final metric in classificationeps
- the regularization to add to the metric creationmaxIterations
- the maximum number of times to adjust the metric for
each classificationvcf
- the default vector collection that will be used for initial
neighbor searchpublic void setK(int k)
k
- the number of neighborspublic int getK()
public void setKn(int kn)
kn
- the number of neighbors to usepublic int getKn()
public void setMaxIterations(int maxIterations)
maxIterations
- the maximum number of times the metric will be updatedpublic int getMaxIterations()
public void setEpsilon(double eps)
eps
- the regularization valuepublic double getEpsilon()
public CategoricalResults classify(DataPoint data)
Classifier
classify
in interface Classifier
data
- the data point to classifypublic void trainC(ClassificationDataSet dataSet, ExecutorService threadPool)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onthreadPool
- the source of threads to use.public void trainC(ClassificationDataSet dataSet)
Classifier
trainC
in interface Classifier
dataSet
- the data set to train onpublic boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
public Classifier clone()
clone
in interface Classifier
clone
in class Object
public static Distribution guessK(DataSet d)
d
- the dataset to get the guess forpublic static Distribution guessKn(DataSet d)
d
- the dataset to get the guess forpublic List<Parameter> getParameters()
Parameterized
getParameters
in interface Parameterized
public Parameter getParameter(String paramName)
Parameterized
getParameter
in interface Parameterized
paramName
- the name of the parameter to obtainCopyright © 2017. All rights reserved.