3.2. KNN
As with the PLS-DA method, 0 and 1 were used to indicate two
categories, 0 represented the normal egg, while 1 represented
the blood-spot egg. After several attempts, the absorbance
values at 576.94 nm and 600.31 nm were used as independent
variables, 0 and 1 were used as the dependent variables. From
the difference of the average spectra of normal eggs and
artificial blood-spot eggs in the range of 500e700 nm (Fig. 4), it
can be seen that 576.94 nm was one of the haemoglobin absorption
peaks, and the difference between the average
spectra of normal eggs and artificial blood-spot eggs at
600.31 nm was zero which indicated that the absorption of the
normal egg and artificial blood-spot egg at this wavelength
was the same, so it can be used as the reference to reduce the
influence of egg size, eggshell colour and thickness etc.
Figure 5 depicts the relationship between the k and the error
rate. From this figure we can see that when the value of k was
7, the error rate reached its lowest value (0.09). Results of KNN
method with k ¼ 7 are as follows: in the training set, four
normal eggs were judged as blood-spot eggs and eight artifi-
cial blood-spot eggs were judge as normal eggs, the total
discrimination rate was 90.8% and in the prediction set, no
normal egg was misjudged and four artificial blood-spot eggs
were judged as normal eggs, the total discrimination rate was
93.8%. Compared to PLS-DA, the total discrimination rates of
the prediction set had increased a little, but it still cannot meet
practical requirements.