public class LWL extends Object implements Classifier, Regressor, Parameterized
NaiveBayes
and
LinearRegression
. uniform kernel fucntion
was used, regardless
of whatever kernel function was set. Constructor and Description |
---|
LWL(Classifier classifier,
int k,
DistanceMetric dm)
Creates a new LWL classifier
|
LWL(Classifier classifier,
int k,
DistanceMetric dm,
KernelFunction kf)
Creates a new LWL classifier
|
LWL(Classifier classifier,
int k,
DistanceMetric dm,
KernelFunction kf,
VectorCollectionFactory<VecPaired<Vec,Double>> vcf)
Creates a new LWL classifier
|
LWL(Regressor regressor,
int k,
DistanceMetric dm)
Creates a new LWL Regressor
|
LWL(Regressor regressor,
int k,
DistanceMetric dm,
KernelFunction kf)
Creates a new LWL Regressor
|
LWL(Regressor regressor,
int k,
DistanceMetric dm,
KernelFunction kf,
VectorCollectionFactory<VecPaired<Vec,Double>> vcf)
Creates a new LWL Regressor
|
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
LWL |
clone() |
DistanceMetric |
getDistanceMetric()
Returns the distance metric in use
|
KernelFunction |
getKernelFunction()
Returns the kernel function that will be used to set the weights.
|
int |
getNeighbors()
Returns the number of neighbors that will be used to create each local model
|
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 |
guessNeighbors(DataSet d)
Guesses the distribution to use for the number of neighbors to consider
|
double |
regress(DataPoint data) |
void |
setDistanceMetric(DistanceMetric dm)
Sets the distance metric that will be used for the nearest neighbor search
|
void |
setKernelFunction(KernelFunction kf)
Sets the kernel function that will be used to set the weights of each
data point in the local set
|
void |
setNeighbors(int k)
Sets the number of neighbors that will be used to create the local model
|
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
void |
train(RegressionDataSet dataSet) |
void |
train(RegressionDataSet dataSet,
ExecutorService threadPool) |
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 LWL(Classifier classifier, int k, DistanceMetric dm)
classifier
- the local classifier tok
- the number of neighbors to create a local classifier fromdm
- the metric to use when selecting the nearest points to a querypublic LWL(Classifier classifier, int k, DistanceMetric dm, KernelFunction kf)
classifier
- the local classifier tok
- the number of neighbors to create a local classifier fromdm
- the metric to use when selecting the nearest points to a querykf
- the kernel function used to weight the local pointspublic LWL(Classifier classifier, int k, DistanceMetric dm, KernelFunction kf, VectorCollectionFactory<VecPaired<Vec,Double>> vcf)
classifier
- the local classifier tok
- the number of neighbors to create a local classifier fromdm
- the metric to use when selecting the nearest points to a querykf
- the kernel function used to weight the local pointsvcf
- the factory to create vector collections for storing the pointspublic LWL(Regressor regressor, int k, DistanceMetric dm)
regressor
- the local regressork
- the number of neighbors to create a local classifier fromdm
- the metric to use when selecting the nearest points to a querypublic LWL(Regressor regressor, int k, DistanceMetric dm, KernelFunction kf)
regressor
- the local regressork
- the number of neighbors to create a local classifier fromdm
- the metric to use when selecting the nearest points to a querykf
- the kernel function used to weight the local pointspublic LWL(Regressor regressor, int k, DistanceMetric dm, KernelFunction kf, VectorCollectionFactory<VecPaired<Vec,Double>> vcf)
regressor
- the local regressork
- the number of neighbors to create a local classifier fromdm
- the metric to use when selecting the nearest points to a querykf
- the kernel function used to weight the local pointsvcf
- the factory to create vector collections for storing the pointspublic 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
supportsWeightedData
in interface Regressor
public void train(RegressionDataSet dataSet, ExecutorService threadPool)
public void train(RegressionDataSet dataSet)
public LWL clone()
public void setNeighbors(int k)
k
- the number of neighbors to obtainpublic int getNeighbors()
public void setDistanceMetric(DistanceMetric dm)
dm
- the distance metric to use for nearest neighbor searchpublic DistanceMetric getDistanceMetric()
public void setKernelFunction(KernelFunction kf)
kf
- the kernel function to use for weightingpublic KernelFunction getKernelFunction()
public static Distribution guessNeighbors(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.