We develop a boundary analysis method, called unsupervised boundary analysis (UBA), based on machine learning algorithms applied to potential fields. Its main purpose is to create a data-driven process yielding a good estimate of the source position and extension, which does not depend on choices or assumptions typically made by expert interpreters, such as low-pass filtering or weights in the enhanced horizontal derivative case. We first test the simple synthetic case of two vertical faults, to understand the robustness of the method. We recognize three classes based on their centroids and find that the source edges could be detected at the transition between the two of them. Subsequently, we apply the UBA to the real magnetometric data of the archaeological site of Torre Galli (Calabria, Italy). We compare the results with those from two different boundary analysis techniques, the enhanced horizontal derivative and the tilt derivative. The main sources are well recognized by our approach and in good agreement with the enhanced horizontal derivative results, but UBA leads us to have a more complete description of the lineaments and to retrieve further features of archaeologic interest in the area. Instead, the tilt derivative features are affected by noise, which makes interpretation more complicated.