One of the ways to improve the reliability of electrical grids is associated with the introduction of complex and resource-intensive algorithms in intelligent electronic devices (IED) that perform the functions of relay protection and automation at substations. Simulation modelling is used to study the features of the protected object functioning and its application makes it possible to take into account the variability of electrical grid states in the formation of IED algorithms, which are characteristic of the analyzed electrical grid section. In addition, this approach makes it possible to use for short circuits detection only those information features that have a high information value in a specific problem of states recognition. Machine learning methods are advisable to use for modern relay protection algorithms implementation. One of such methods is the k-nearest neighbours method. The article substantiates the effectiveness of the method application in comparison with the conventional algorithms on the example of protection of an electrical grid section with a distributed generation source. The reported study was funded by RFBR, project number 19-38-90144.