필터 지우기
필터 지우기

Doubt in KNN classifier using Chi Square distance

조회 수: 2 (최근 30일)
Shan Sha
Shan Sha 2019년 1월 29일
The rows of X and Y correspond to observations, and the columns are, in general, dimensions (for example, predictors).
The chi-square distance between j-dimensional points x and z is
where is the weight associated with dimension j.
Choose weights for each dimension, and specify the chi-square distance function. The distance function must:
  • Take as input arguments one row of X, e.g., x, and the matrix Z.
  • Compare x to each row of Z.
  • Return a vector D of length , where is the number of rows of Z. Each element of D is the distance between the observation corresponding to x and the observations corresponding to each row of Z.
w = [0.4; 0.6];
chiSqrDist = @(x,Z)sqrt((bsxfun(@minus,x,Z).^2)*w);
This example uses arbitrary weights for illustration.
Find the indices of the three nearest observations in X to each observation in Y.
k = 3;
[Idx,D] = knnsearch(X,Y,'Distance',chiSqrDist,'k',k);
I have referred this in mathworks. I m not clear with what Z represent. so please explain in detail?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by