Skip to main content

k-NN based fault detection and classification methods for power transmission systems


This paper deals with two new methods, based on k-NN algorithm, for fault detection and classification in distance protection. In these methods, by finding the distance between each sample and its fifth nearest neighbor in a pre-default window, the fault occurrence time and the faulty phases are determined. The maximum value of the distances in case of detection and classification procedures is compared with pre-defined threshold values. The main advantages of these methods are: simplicity, low calculation burden, acceptable accuracy, and speed. The performance of the proposed scheme is tested on a typical system in MATLAB Simulink. Various possible fault types in different fault resistances, fault inception angles, fault locations, short circuit levels, X/R ratios, source load angles are simulated. In addition, the performance of similar six well-known classification techniques is compared with the proposed classification method using plenty of simulation data.


Distance protection is one of the major protections of power systems, utilized for detection, classification, and location of short circuit faults. In the detection stage, any change caused by different normal and abnormal conditions is recognized. Then in the classification stage, the type of faults (Ag, Bg, Cg, ABg, BCg, CAg, AB, BC and CA) is determined.

In the fault location stage, the distance between the fault and the relay is determined. Due to importance of speed and accuracy of fault detection and classification units, too many investigations have been dedicated to these fields.

When a fault occurs in the power system, variables such as current, power, power factor, voltage, impedance, and frequency change. Many detection techniques detect fault occurrence by comparing the post-fault values of these variables with their values during system normal operation. Some of fault detection methods are based on Kalman filter [1], first derivative method, Fourier transform (FT), and least squares [2]. Some other methods are based on differential equations [2], travelling waves [3, 4], phasor measurement [5], discrete wavelet transform [6], fuzzy logic, genetic algorithm [7] and neural network [8].

Also, many efforts have been made in the field of fault classification, which can be broadly categorized in two main groups. First, methods that are based on signatures of the signals and definition of some criteria such as: discrete wavelet transform (DWT) [9,10,11,12,13], Fourier transform (FT), S-transform [14], adaptive Kalman filtering [15], sequential components [16, 17], and synchronized voltage and current samples [18]. The second group includes the methods based on artificial intelligence techniques such as: Artificial Neural Networks (ANN) [19,20,21], fuzzy logic [22, 23], Support Vector Machine (SVM) [24,25,26], and decision-tree [27].

In this paper, two new methods are presented for detection and classification of faults. A moving window with the length of half cycle of power frequency is considered and the RMS value of the current samples is computed in the window. The RMS value obtained in the last window before fault, in which the fault instant is the last sample, is saved. The current waveforms are divided by the saved RMS value. Then, k-NN algorithm is applied to these normalized waveforms and their squares in classification and detection methods, respectively.

In the detection method, a moving window with the length of half cycle is considered. In the window, besides finding the fifth nearest neighbor for each point of the squared normalized currents, the distance between each point and its corresponding neighbor is found. By comparing the maximum distance in each window with an adaptive threshold, the fault is detected.

The classification method has a similar trend, but the k-NN algorithm is applied to the instantaneous values of normalized three-phase currents and length of the window is three quarters of a cycle.

Various scenarios including different fault types, fault inception angles, fault resistances, fault locations, sources phase angles, X/R ratios, and short circuit levels are used to evaluate the performance of the methods in a simulated typical five-bus power system. Also, in order to evaluate the performance of the proposed classification method, it is compared with six other similar methods. The methods are compared in terms of delay time and accuracy using a data set including 450 different cases. Beside the simplicity, the proposed techniques have small calculation burden and high accuracy. Moreover, the methods performance is preserved in different conditions.

The remainder of this paper is organized as follows: Section 2 presents the under-study power system. In Section 3, basis of k-NN and its application for fault detection as well as an improved fault detection algorithm are presented. In Section 4, the proposed classification algorithm is introduced. The simulation results are presented in Section 5. A comparison between the performance of the proposed method and some other similar methods is presented in Section 6. Finally, the main conclusions are presented in Section 7.

Simulated power system

A five-bus power system is modeled in MATLAB Simulink. A schematic single line diagram of the under study system is presented in Fig. 1. The modeled system comprises of two generators, four transformers and active and reactive loads connected to buses 4 and 5. Detailed specification of the system components are as follows:

  • Generators: Rated line to line voltage is 20 kV, three-phase short-circuit power is 1000 MVA, frequency is 50 Hz, X/R ratio is 10. Also it is assumed that the angles of sources 1 and 2 are 0 and −10 degree, respectively.

  • Transformers: Rated power is 600 MVA, voltage ratio is 20/230 kV with delta-star-grounded connection, its primary and secondary impedances are 0.06 + j0.3 Ω and 0.397 + j2.12 Ω.

  • Lines: All of line impedances are 0.02 + j0.15 Ω/km. Lines 1–2, 2–3, 3–4, 4–1, and 5–2 are 200, 70, 120, 40, and 50 km, respectively.

  • Loads: The active and reactive powers of load 1 are 400 MW and 100 MVAr, respectively. The active and reactive powers of load 2 are 100 MW and 50 MVAr, respectively.

Fig. 1

Schematic diagram of the power system under study

Sampling frequency: It is equal to 10 kHz.

The proposed change detection scheme

k-Nearest Neighbor algorithm (k-NN)

The k-NN algorithm is a nonparametric classification method that can achieve high classification accuracy in problems with non-normal and unknown distributions. For a particular sample, k closest points between the data and the sample are found. Usually, the Euclidean distance is used, where one point’s components are utilized to compare with the components of another point.

The basis of k-NN algorithm is a data matrix that consists of N rows and M columns. Parameters N and M are the number of data points and dimension of each data point, respectively. Using the data matrix, a query point is provided and the closest k points are searched within this data matrix that are the closest to this query point.

In general, the Euclidean distance between the query and the rest of the points in the data matrix is calculated. After this operation, N Euclidean distances which symbolize the distances between the query with each corresponding point in the data set are achieved. Then, the k nearest points to the query can be simply searched by sorting the distances in ascending order and retrieving those k points that have the smallest distance between the data set and query.

The proposed fault detection algorithm

Considering fixed sampling frequency, Euclidean distance between each sample and other samples of a considered sliding window varies when a change occurs. In fact, Euclidean distance represents differences between the samples values. k-NN algorithm can derive variation of the Euclidean distance for change detection. In this work, a sliding window with length of half cycle of power frequency is moved on squared normalized current waveform of each phase. Then, k-NN algorithm is applied to the samples of each window and the fifth nearest neighbor for each sample and the distance between them is obtained. Finally, the maximum distance is selected for each phase named Ma,D, Mb,D, and Mc,D. Based on different simulations, it is confirmed that the fifth nearest neighbor gives the best accuracy. In addition to the derived fifth neighbor, the distance between each sample and its corresponding fifth neighbor is derived. Considering sampling frequency 10 kHz, there are 100 samples in each half cycle, result in 100 different distances. Among them, the maximum distance is compared with a certain threshold value to detect fault condition.

In case of change occurrence, the sample corresponding to the change enters the end of the window. It is observed that after three or four samples, the maximum distance of some or all of the phases exceed the threshold value. By considering an appropriate value for the threshold, it is possible to detect the fault after 0.2 ms to 0.4 ms. In this study, Ith,D = 0.0667 is selected for fault detection threshold. Flowchart of the proposed algorithm for change detection is shown in Fig. 2.

Fig. 2

The proposed change detection method

In Fig. 3, the proposed criterion for some different fault cases is presented. The instants of change occurrence and the relevant detection times, are shown.

Fig. 3

The proposed criterion. a Fault AB, negligible resistance, t0 = 0.2002 s. b Fault BCg, Rf = 10 Ω, t0 = 0.2042 s c Fault AC, Rf = 40 Ω, t0 = 0.2062 s d Switching of load 200 MW, t0 = 0.2032 s

The proposed fault classification scheme

The general approach for fault classification is the same as detection method. However, in the classification method the k-NN algorithm is implemented in a window applied to normalized current waveforms with length of three quarters of a cycle, called analysis window. The considered k value and length of analysis window are selected based on different simulations to achieve the best accuracy and speed for the classification.

In Fig. 4, three-phase distances values for some different fault types with negligible resistance and inception instant equal to 0.2002 s are presented. In these figures, the fifth nearest neighbor for each sample of the analysis window is shown.

Fig. 4

The distance between each sample and its corresponding neighbor in the analysis window. a Fault AB, negligible resistance, t0 = 0.2002 s. b Fault BCg, negligible resistance, t0 = 0.2002 s. c Fault Cg, negligible resistance, t0 = 0.2002 s

It is obvious, the distance between each sample of current and its fifth neighbor is a suitable criterion for fault classification. By choosing the maximum distance for each phase (Ma,C, Mb,C, and Mc,C) and comparing it with a threshold value, the type of fault can be determined. It is obvious that the values of Ma,C, Mb,C, and Mc,C are obtained exactly the same as detection method, but in a window with the length of three quarters of a cycle. The best threshold value is selected using different simulations.

Some other considerations are taken into account for the classification method, which are as follows:

  1. 1.

    For discrimination between two phase faults (LL) and grounded two phase faults (LL-g), the means of three phases’ corresponding current samples in the analysis window is obtained and the maximum mean is utilized as follows:

    $$ Mi=\max \left(\frac{ia+ ib+ ic}{3}\right)\kern0.5em in the analysis window $$

In case of grounded faults (LL-g), Mi > 100 A and Mi < 1 A for two phase faults (LL). This criterion can discriminate between LL and LL-g with a very high accuracy.

  1. 2.

    In order to omit the initial transient behavior of the signal, twenty first samples of the window are not considered.

The flowchart of the classification method is presented in Fig. 5 . Threshold Ith,C is set to 0.1108.

Fig. 5

The proposed classification method

Test cases and simulation results

Case 1: Various fault types

Different fault types are applied at the middle of line 1–2 of the power system shown in Fig. 1. The results are shown in Table 1. The faults are solid and applied at an identical inception instant 0.2002 s. Results including the discrimination criteria (Mi) and the maximum distance of each phase are presented in Table 1. From the results, one can conclude that the proposed method is able to classify different faults using the mentioned rules.

Table 1 Results of various fault types

The results for each group of phase-to-ground, phase-to-phase-to-ground, and phase-to-phase faults are similar. Therefore, hereafter only four types of faults including: Ag, ABg, AB, and ABC are considered.

Case 2: Various inception instants

In Table 2, the results for different inception instants are presented for the mentioned faults. The inception instant is varied by step 3 ms. Faults are also considered solid type. The results confirm that the proposed method is able to classify faults at different inception instants.

Table 2 Results of various fault inception instants

Case 3: Various fault resistances

In Table 3, the results of this case study for fault resistances 10, 30, 50,70, and 90 Ω, are shown. The faults are applied at an identical inception instant 0.2002 s. From the results, it is confirmed that the proposed method has acceptable performance for fault resistance up to 90 Ω. Although the technique can also classify the faults with resistances more than 90 Ω, the performance may be less than the acceptable value.

Table 3 Results of various fault resistances

Case 4: Various fault locations

One of the other challenges that should be considered for a fault identification technique is location of the fault in the transmission lines. In this test case, the system is analyzed with a fault applied at 0%, 20%, 40%, 60%, 80%, and 100% of the transmission line 1–2. Results of the four fault types are shown in Table 4. The faults are solid type and applied at an identical inception instant 0.2002 s.

Table 4 Results of various fault locations

In addition, several faults for locations more than 100% are simulated. The faults are applied at 105%, 110%, and 120% of the transmission line 2–5 at an identical inception instant 0.2002 s. The results are tabulated in Table 5.

Table 5 Results of fault locations more than 100%

From the results, it can be concluded that the performance of the proposed method is preserved even for locations more than 100%. It should be mentioned that the performance of the proposed method degrades for locations more than 120%.

Case 5: Various sources load angles

The results for various angles, according different inception instant, fault resistances, and fault types verify that proposed method classify the faults in different values of sources load angles. For abbreviation, the results relevant to this case are not presented.

Case 6: Various X/R ratios

Different X/R ratios impact on the performance of the proposed method is also investigated, considering different inception instant, fault resistances, and fault types. From the results, it can be concluded that accuracy of the proposed method is preserved for different values of X/R ratios.

Case 7: Various short circuit levels

The performance of the proposed method is also evaluated for various sources short circuit levels. The algorithm also has desirable performance for these cases.

Case 8: Various load levels

In Table 6, the results of some simulated cases for no-load and loads with fraction of the nominal value are shown. It should be noted that for each load, different load values are considered in the condition of no-load of the other one. All the faults are applied in the location of 80% of the transmission line 1–2. From the results, one can observe that the performance of the proposed method is preserved in different load levels.

Table 6 Results of various load levels

Case 9: Current transformer saturation

The performance of the method is also evaluated during current transformer saturation. Two typical cases are considered. The faults are solid type and applied at an identical inception instant 0.2345 s. The classification criteria for both cases are shown in Fig. 6 and Table 7. It is observed that the proposed method is able to classify the faults during current transformer saturation.

Fig. 6

The distance between each sample and its corresponding neighbor in the analysis window. a Fault AB, negligible resistance, t0 = 0.2345 s. b Fault ABC, negligible resistance, t0 = 0.2345 s

Table 7 Results of two fault cases during current transformer saturation

A comparison with other techniques

The performance of the proposed method is compared with six other similar approaches in this Section. All of the methods are evaluated using an identical data set in similar conditions. The six methods are briefly reviewed as follows:

a. Sequence Component [16]: This technique classifies the faults using the phase differences between positive and negative sequences. Also, relative magnitudes of negative and zero sequences from pre-fault to the fault stage are used to distinguish between phase-to-phase (LL) and phase-to-phase-to-ground (LLg) faults.

b. Alienation Coefficients [28]: In this algorithm, alienation technique is applied to two half successive cycles with the same polarity. The alienation coefficients of the successive cycles as two dependent variables are calculated. This technique is capable of classification using only three-phase current waveforms and its delay time is half cycle of power frequency. Also, another version of this approach is presented in [29].

c. Discrete Wavelet Transform [23]: Daubechies family of wavelet transform is used in this technique. Third level output among different decomposed levels is used and the summation of detailed current signals for each phase (Sa, Sb, and Sc) is obtained. If the summation of Sa, Sb, and Sc is equal to zero, then the fault type is either three-phase or LL, otherwise, it is phase-to-ground (Lg) or LLg fault.

d. Fuzzy Logic [22]: The prerequisite of this technique is fault occurrence time. In this algorithm, using measured current samples, some specific characteristics for the samples are defined for the fault classification. The technique takes three quarters of a cycle to classify the fault.

e. Using RMS Values of current: A simple approach to classify the faults is based on comparing the RMS values of three-phase current waveforms with a certain threshold. The RMS values of the phases are obtained using Fourier transform in a half cycle window after fault occurrence. Discrimination between LL and LLg is determined using zero sequence component of current, which is large for LLg and zero for LL.

f. Using RMS Values of Voltage: This technique is exactly the same as previous method for three-phase voltage signals. Type of fault is determined when the RMS values of the voltages become less than a certain threshold.

The performance of the proposed method is compared with the above-mentioned methods based on following factors; the results are tabulated in Table 8:

  • Fault resistances

  • Fault inception instants

  • Fault locations

  • Generators X/R ratios

  • Phase difference between two generators

  • Generators short circuit levels

  • Delay operation time

  • Error percentage

Table 8 Comparison between the different methods

The number of the whole cases considered in this Section is 410; 200 cases for different fault resistances and inception instants, 50 cases for different fault locations, 70 cases for different sources X/R ratios, 50 cases for different sources angles, and 40 cases for different short circuit levels.

In Table 8, error percentages for the above mentioned factors are calculated as the ratio of number of mal-function operations to number of the relevant cases. Then, total error percentage for each method is calculated as ratio of number of whole mal-function operations to number of whole the cases.

Techniques a and d have a delay time 15 ms and techniques b, c, e, and f have a delay time 10 ms. Among the methods with delay time 15 ms, fuzzy logic has a very good performance with only 0.49% error.

The proposed technique has a good performance with error percentage of 1.95% and average delay time of 15 ms. Based on the calculated total error percentage and delay time, it is confirmed that the proposed method has acceptable performance in comparison with other methods.


Two simple methods for fault detection and classification are presented in this paper. The methods are based on k-NN algorithm. Plenty of simulations were used in order to evaluate the performance of the methods. The performance of the proposed classification method is compared with six other similar methods. From the results, the good accuracy and speed of the methods are confirmed. The classification technique has accuracy about 98% for the considered data set with 15 ms average delay time.


  1. 1.

    Chowdhury, F. N., Christensen, J. P., & Aravena, J. L. (1991). Power system fault detection and state estimation using Kalman filter with hypothesis testing. IEEE Transactions on Power Delivery, 6(3), 1025–1030.

    Article  Google Scholar 

  2. 2.

    Öhrström, M., & Söder, L. (2002). Fast fault detection for power distribution systems. Power and energy systems (PES), Marina del Rey, USA, may 13–15.

  3. 3.

    Magnago, F. H., & Abur, A. (1999). A new fault location technique for radial distribution systems based on high frequency signals. IEEE in Power Engineering Society Summer Meeting, 1, 426–431.

    Google Scholar 

  4. 4.

    Xiangjun, Z., Yuanyuan, W., Yao, X. (2010). Faults detection for power systems. INTECH Open Access Publisher. In W. Zhang (E.d.), Fault Detection (pp. 512). InTech. ISBN 978-953-307-037-7. doi:10.5772/56395.

  5. 5.

    Gopakumar, P., Reddy, M. J. B., & Mohanta, D. K. (2015). Transmission line fault detection and localisation methodology using PMU measurements. Journal of IET, Generation, Transmission & Distribution, 9(11), 1033–1042.

    Article  Google Scholar 

  6. 6.

    Bezerra Costa, F. (2014). Fault-induced transient detection based on real-time analysis of the wavelet coefficient energy. IEEE Transactions on Power Delivery, 29(1), 140–153.

    Article  Google Scholar 

  7. 7.

    Haghifam, M. R., Sedighi, A. R., & Malik, O. P. (2006). Development of a fuzzy inference system based on genetic algorithm for high-impedance fault detection. Journal of IEE Proceedings-Generation, Transmission and Distribution, 153(3), 359–367.

    Article  Google Scholar 

  8. 8.

    Baqui, I., Zamora, I., Mazón, J., & Buigues, G. (2011). High impedance fault detection methodology using wavelet transform and artificial neural networks. Journal of Electric Power Systems Research, 81(7), 1325–1333.

    Article  Google Scholar 

  9. 9.

    Shaik, A. G., & Pulipaka, R. R. V. (2015). A new wavelet based fault detection, classification and location in transmission lines. International Journal of Electrical Power & Energy Systems, 64, 35–40.

    Article  Google Scholar 

  10. 10.

    Torabi, N., Karrari, M., Menhaj, M. B., Karrari, S. (2012). 'Wavelet Based Fault Classification for Partially Observable Power Systems. IEEE, In Asia-Pacific Power and Energy Engineering Conference (APPEEC) (pp. 1–6).

  11. 11.

    Usama, Y., Lu, X., Imam, H., Sen, C., & Kar, N. (2013). Design and implementation of a wavelet analysis-based shunt fault detection and identification module for transmission lines application. IET Journal of Generation, Transmission & Distribution, 8(3), 431–444.

    Google Scholar 

  12. 12.

    Guillen, D., Arrieta Paternina, M. R., Zamora, A., Ramirez, J. M., & Idarraga, G. (2015). Detection and classification of faults in transmission lines using the maximum wavelet singular value and Euclidean norm. IET Journal of Generation, Transmission & Distribution, 9(15), 2294–2302.

    Article  Google Scholar 

  13. 13.

    Liu, Z., Han, Z., Zhang, Y., & Zhang, Q. (2014). Multiwavelet packet entropy and its application in transmission line fault recognition and classification. IEEE Transactions on Neural Networks and Learning Systems, 25(11), 2043–2052.

    Article  Google Scholar 

  14. 14.

    Dash, P. K., Das, S., & Moirangthem, J. (2015). Distance protection of shunt compensated transmission line using a sparse S-transform. IET Journal of Generation, Transmission & Distribution, 9(12), 1264–1274.

    Article  Google Scholar 

  15. 15.

    Girgis, A., & Makram, E. B. (1988). Application of adaptive Kalman filtering in fault classification, distance protection, and fault location using microprocessors. IEEE Transactions on Power Systems, 3(1), 301–309.

    Article  Google Scholar 

  16. 16.

    Adu, T. (2002). An accurate fault classification technique for power system monitoring devices. IEEE Transactions on Power Delivery, 17(3), 684–690.

    Article  Google Scholar 

  17. 17.

    Rahmati, A., & Adhami, R. (2014). A fault detection and classification technique based on sequential components. IEEE Transactions on Industry Applications, 50(6), 4202–4209.

    Article  Google Scholar 

  18. 18.

    Esmaeilian, A., & Kezunovic, M. (2014). Transmission-line fault analysis using synchronized sampling. IEEE Transactions on Power Delivery, 29(2), 942–950.

    Article  Google Scholar 

  19. 19.

    Butler, K. L., Momoh, J. (1993). Detection and classification of line faults on power distribution systems using neural networks. IEEE Proceedings of the 36th Midwest Symposium, In Circuits and Systems. (pp. 368–371).

  20. 20.

    Upendar, J., Gupta, C. P., Singh, G. K. (2008). ANN based power system fault classification. IEEE, In Region 10 Conference (TENCON), November, (pp. 1–6).

  21. 21.

    Tayeb, E. B. M., Rhim, O. A. A. A. (2011). Transmission line faults detection, classification and location using artificial neural network. IEEE, international conference, utility exhibition on power and energy systems: Issues & prospects for Asia (ICUE), September.

  22. 22.

    Mahanty, R. N., & Gupta, P. D. (2007). A fuzzy logic based fault classification approach using current samples only. Journal of Electric power systems research, 77(5), 501–507.

    Article  Google Scholar 

  23. 23.

    Reddy, M. J., & Mohanta, D. K. (2007). A wavelet-fuzzy combined approach for classification and location of transmission line faults. International Journal of Electrical Power & Energy Systems, 29(9), 669–678.

    Article  Google Scholar 

  24. 24.

    Shahid, N., Aleem, S. A., Naqvi, I. H., Zaffar, N. (2012). Support vector machine based fault detection & classification in smart grids. IEEE, In Globecom Workshops (GC Wkshps), December, (pp. 1526–1531).

  25. 25.

    Livani, H., Evrenosoğlu, C. Y. (2012). A fault classification method in power systems using DWT and SVM classifier. IEEE PES, In Transmission and Distribution Conference and Exposition (T&D), May, 1–5.

  26. 26.

    Moravej, Z., Pazoki, M., & Khederzadeh, M. (2015). New pattern-recognition method for fault analysis in transmission line with UPFC. IEEE Transactions on Power Delivery, 30(3), 1231–1242.

    Article  Google Scholar 

  27. 27.

    Swetapadma, A., & Yadav, A. (2015). Data-mining-based fault during power swing identification in power transmission system. Journal of IET Science, Measurement & Technology, 10(2), 130–139.

    Article  Google Scholar 

  28. 28.

    Masoud, M. E., & Mahfouz, M. M. A. (2010). Protection scheme for transmission lines based on alienation coefficients for current signals. IET Journal of Generation, transmission & distribution, 4(11), 1236–1244.

    Article  Google Scholar 

  29. 29.

    Samet, H., Shabanpour-Haghighi, A., & Ghanbari, T. (2017). A fault classification technique for transmission lines using an improved alienation coefficients technique. doi:10.1002/etep.2235.

Download references

Author information




All authors read and approved the final manuscript.

Corresponding author

Correspondence to Haidar Samet.

Ethics declarations

Competing interests

The authors declare that they have no competing interests.

Rights and permissions

Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (, which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Asadi Majd, A., Samet, H. & Ghanbari, T. k-NN based fault detection and classification methods for power transmission systems. Prot Control Mod Power Syst 2, 32 (2017).

Download citation


  • Short circuit faults
  • Fault detection
  • Fault classification
  • K nearest neighbor algorithm