The document discusses a method called Automatic Interface Detection Algorithm (AIDA) that uses near-infrared spectroscopy and machine learning to detect transitions between pure products and transmix batches in real-time in pipelines. AIDA transforms NIR spectra into a decomposed "process space" where similar spectra cluster together. It draws a sphere around spectra in this space, and if the percentage of points within the sphere exceeds a threshold it is labeled as pure product, otherwise it is labeled as transmix. The method was validated on a diesel and gasoline pipeline and showed accurate detection of interface transitions. Future developments could include automating parameters, applying it to crude oil pipelines, and using it to enhance pricing models.