Catalano.MachineLearning.Regression
Class KNearestNeighbors
- java.lang.Object
-
- Catalano.MachineLearning.Regression.KNearestNeighbors
-
- All Implemented Interfaces:
- IRegression, java.io.Serializable, java.lang.Cloneable
public class KNearestNeighbors extends java.lang.Object implements IRegression, java.io.Serializable
K Nearest Neighbors for regression.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description KNearestNeighbors()Initializes a new instance of the KNearestNeighbors class.KNearestNeighbors(int k)Initializes a new instance of the KNearestNeighbors class.KNearestNeighbors(int k, IDivergence divergence)Initializes a new instance of the KNearestNeighbors class.KNearestNeighbors(int k, IMercerKernel kernel)Initializes a new instance of the KNearestNeighbors class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description IRegressionclone()Clone of the object.intgetK()Get number of neighbors.voidLearn(DatasetRegression dataset)Learn.voidLearn(double[][] input, double[] output)Learn.doublePredict(double[] feature)Predict.voidsetK(int k)Set number of neighbors.
-
-
-
Constructor Detail
-
KNearestNeighbors
public KNearestNeighbors()
Initializes a new instance of the KNearestNeighbors class.
-
KNearestNeighbors
public KNearestNeighbors(int k)
Initializes a new instance of the KNearestNeighbors class.- Parameters:
k- Number of neighbors.
-
KNearestNeighbors
public KNearestNeighbors(int k, IDivergence divergence)Initializes a new instance of the KNearestNeighbors class.- Parameters:
k- Number of neighbors.divergence- Divergence.
-
KNearestNeighbors
public KNearestNeighbors(int k, IMercerKernel kernel)Initializes a new instance of the KNearestNeighbors class.- Parameters:
k- Number of neighbors.kernel- Kernel.
-
-
Method Detail
-
getK
public int getK()
Get number of neighbors.- Returns:
- Number of neighbors.
-
setK
public void setK(int k)
Set number of neighbors.- Parameters:
k- Number of neighbors.
-
Learn
public void Learn(DatasetRegression dataset)
Description copied from interface:IRegressionLearn.- Specified by:
Learnin interfaceIRegression- Parameters:
dataset- Dataset regression.
-
Learn
public void Learn(double[][] input, double[] output)Description copied from interface:IRegressionLearn.- Specified by:
Learnin interfaceIRegression- Parameters:
input- Input.output- Output.
-
Predict
public double Predict(double[] feature)
Description copied from interface:IRegressionPredict.- Specified by:
Predictin interfaceIRegression- Parameters:
feature- Feature.- Returns:
- Value.
-
clone
public IRegression clone()
Description copied from interface:IRegressionClone of the object.- Specified by:
clonein interfaceIRegression- Overrides:
clonein classjava.lang.Object- Returns:
- A new copy of the object.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG