k-Nearest Neighbors (kNN) Classifier

버전 2.2.1 (35.8 KB) 작성자: David Ferreira
Multi-class Classification with the kNN
다운로드 수: 2.1K
업데이트 날짜: 2020/10/28

Function
1. kNNeighbors.predict(_)
2. kNNeighbors.find(_)

Description
1. Returns the estimated labels of one or multiple test instances.
2. Returns the indices and the respective distances of the k nearest training instances.

Examples using Iris Data Set

load fisheriris

X = meas;
Y = species;
Xnew = [min(X);mean(X);max(X)];
k = 5;
metric = 'euclidean';

mdl = kNNeighbors(k,metric);
mdl = mdl.fit(X,Y);
Ypred = mdl.predict(Xnew)

Ypred =

'setosa'
'versicolor'
'virginica'


Ynew = {'versicolor';'versicolor';'virginica'};
accuracy = accuracy_score(Ypred,Ynew)

accuracy =

0.6667

See examples in the script files.

인용 양식

David Ferreira (2019). k-Nearest Neighbors (kNN) (https://www.mathworks.com/matlabcentral/fileexchange/67018-k-nearest-neighbors-knn), MathWorks. Retrieved January 23, 2019.

MATLAB 릴리스 호환 정보
개발 환경: R2016a
모든 릴리스와 호환
플랫폼 호환성
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!

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
2.2.1

See release notes for this release on GitHub: https://github.com/ferreirad08/kNNeighborsClassifier/releases/tag/2.2.1

2.2.0

See release notes for this release on GitHub: https://github.com/ferreirad08/k-Nearest-Neighbors-kNN-Algorithm/releases/tag/2.2.0

2.1.9

See release notes for this release on GitHub: https://github.com/ferreirad08/k-Nearest-Neighbors-kNN-Algorithm/releases/tag/2.1.9

2.1.8

Find function added

2.1.7

Description correction

2.1.6

Description correction

2.1.5

Description correction

2.1.4

Description correction

2.1.3

3-D chart added and cell type label support.

2.1.2

The plotting 3-D function was added in the main algorithm.

2.1.1

More markers were added to the chart.

2.1.0

The plotting function was added in the main algorithm.

2.0.9

Function Pack

2.0.8

Title correction

2.0.7

Title correction

2.0.6

Added to github.

2.0.5

New tools have been added, bringing a more complete algorithm.

2.0.4

Simplification in k nearest instances and k nearest labels

2.0.3

Basic update

2.0.2

Update in maximum frequency

2.0.1

Simplification in frequency verification

2.0.0

Check the frequencies using 'histcounts'

1.62

Title correction

1.61

Correction of the k nearest labels.

1.60

Returns the k nearest labels.

1.54

Basic update

1.53

Updating the Euclidean distance between two points

1.52

Description correction

1.51

Description correction

1.5

Elements sorted by "sort" function and reduced processing time by approximately 1/3.

1.1.0.0

Update of the calculation of the Euclidean distance between two points

1.0.0.0

Description correction
It was added the verification of the dimensions of the matrices.

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.