For that, there's a whole domain of AI called machine learning. Machine learning is such a vital step that it's often confused for AI.