This machine implements the K-nearest-neighbors (KNN) algorithm.
Inheritance:
Public Fields
-
int K
- The number of nearest neighbors.
-
real* distances
- For each nearest neighbor, keeps its distance to the current input
-
int* indices
- For each nearest neighbor, keeps its index in the dataset
-
DataSet* data
- The dataset that contains the potential neaghbors
-
int n_outputs
- the size of the output vector
-
int* real_examples
- the indices of the training examples
Public Methods
-
KNN(int n_outputs_, int K_)
-
virtual void setK(int K_)
- change the value of K
Inherited from Machine:
Public Fields
-
Sequence* outputs
Public Methods
-
virtual void forward(Sequence* sequence)
-
virtual void reset()
-
virtual void setDataSet(DataSet* dataset_)
Inherited from Object:
Public Fields
-
Allocator* allocator
Public Methods
-
void addOption(const char* name, int size, void* ptr, const char* help="")
-
void addIOption(const char* name, int* ptr, int init_value, const char* help="")
-
void addROption(const char* name, real* ptr, real init_value, const char* help="")
-
void addBOption(const char* name, bool* ptr, bool init_value, const char* help="")
-
void addOOption(const char* name, Object** ptr, Object* init_value, const char* help="")
-
void setOption(const char* name, void* ptr)
-
void setIOption(const char* name, int option)
-
void setROption(const char* name, real option)
-
void setBOption(const char* name, bool option)
-
void setOOption(const char* name, Object* option)
-
virtual void loadXFile(XFile* file)
-
virtual void saveXFile(XFile* file)
-
void load(const char* filename)
-
void save(const char* filename)
-
void* operator new(size_t size, Allocator* allocator_=NULL)
-
void* operator new(size_t size, Allocator* allocator_, void* ptr_)
-
void operator delete(void* ptr)
Documentation
This machine implements the K-nearest-neighbors (KNN) algorithm.
Given a dataset (in the constructor), the forward method returns
for a given input the average of the outputs of the K nearest examples
(in the input space, using the Euclidean distance). As a side effect,
the machine also keep the table of distances of the K-nearest-neighbors.
- int K
- The number of nearest neighbors. Controls the capacity of the machine
- real* distances
- For each nearest neighbor, keeps its distance to the current input
- int* indices
- For each nearest neighbor, keeps its index in the dataset
- DataSet* data
- The dataset that contains the potential neaghbors
- int n_outputs
- the size of the output vector
- int* real_examples
- the indices of the training examples
- KNN(int n_outputs_, int K_)
- virtual void setK(int K_)
- change the value of K
- This class has no child classes.
- Author:
- Samy Bengio (bengio@idiap.ch)
Alphabetic index HTML hierarchy of classes or Java
This page was generated with the help of DOC++.