현재 Ethem Alpaydin의 "Introduction to machine learning"을 읽었으며 가장 가까운 중심 분류 장치를 발견하고 구현하려고했습니다. 나는 정확하게 분류자를 구현 한 것 같지만 68 %의 정확도를 얻고 있습니다. 따라서 가장 가까운 중심 분류기 자체가 비효율적입니까, 아니면 구현시 오류가 있습니까 (아래)?가장 가까운 중심 분류기는 실제로 비효율적입니까?
데이터 세트는 1,372 데이터 포인트 각각 4 개 기능을 가진 2 개 출력 클래스가 포함되어 내 MATLAB 구현 :
DATA = load("-ascii", "data.txt");
#DATA is 1372x5 matrix with 762 data points of class 0 and 610 data points of class 1
#there are 4 features of each data point
X = DATA(:,1:4); #matrix to store all features
X0 = DATA(1:762,1:4); #matrix to store the features of class 0
X1 = DATA(763:1372,1:4); #matrix to store the features of class 1
X0 = X0(1:610,:); #to make sure both datasets have same size for prior probability to be equal
Y = DATA(:,5); # to store outputs
mean0 = sum(X0)/610; #mean of features of class 0
mean1 = sum(X1)/610; #mean of featurs of class 1
count = 0;
for i = 1:1372
pre = 0;
cost1 = X(i,:)*(mean0'); #calculates the dot product of dataset with mean of features of both classes
cost2 = X(i,:)*(mean1');
if (cost1<cost2)
pre = 1;
end
if pre == Y(i)
count = count+1; #counts the number of correctly predicted values
end
end
disp("accuracy"); #calculates the accuracy
disp((count/1372)*100);