Analysis in high-energy physics usually deals with data samples populated from different sources. One of the most widely used ways to handle this is the sPlot technique. In this technique the results of a maximum likelihood fit are used to assign weights that can be used to disentangle signal from background. Some events are assigned negative weights, which makes it difficult to apply machine learning methods. Loss function becomes unbounded and the underlying optimization problem non-convex. In this contribution, we propose a mathematically rigorous way to apply Machine Learning methods on data with weights obtained by the sPlot. Examples of applications are also shown.