K Nearest Neighbors

버전 1.4.0.0 (640 Bytes) 작성자: Ani
Program to find the k - nearest neighbors (kNN) within a set of points.
다운로드 수: 23.1K
업데이트 날짜: 2009/3/26

라이선스 없음

Program to find the k - nearest neighbors (kNN) within a set of points.
Distance metric used: Euclidean distance

Usage:
[neighbors distances] = kNearestNeighbors(dataMatrix, queryMatrix, k);
dataMatrix (N x D) - N vectors with dimensionality D (within which we search for the nearest neighbors)
queryMatrix (M x D) - M query vectors with dimensionality D
k (1 x 1) - Number of nearest neighbors desired

Example:
a = [1 1; 2 2; 3 2; 4 4; 5 6];
b = [1 1; 2 1; 6 2];
[neighbors distances] = kNearestNeighbors(a,b,2);

Output:
neighbors =
1 2
1 2
4 3

distances =
0 1.4142
1.0000 1.0000
2.8284 3.0000

인용 양식

Ani (2024). K Nearest Neighbors (https://www.mathworks.com/matlabcentral/fileexchange/15562-k-nearest-neighbors), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2007b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.4.0.0

Users must NOW include a separate query matrix. This allows more input flexibility.

1.1.0.0

Users must not include a separate query matrix. This allows more input flexibility.

1.0.0.0

I am not modifying the file. Just moving it to the Statistics and Probability section.