Machine learning is a fun new(er) way to solve problems.
Rather than programming an algorithm for answering a question about our data, we instead can train a "neural network" with a set of training data. Once we have a trained network, we can use it to predict outcomes.
In this example, we will train a neural network to distinguish between dark and light colors and pick the appropriate color of text to go over the top. To do this without machine learning, there is no single solution that will always get it right (see this blog post https://24ways.org/2010/calculating-color-contrast)