… and there might be situations where you seem like the perfect fit and still get a rejection.
In this case keep it with the thought: “Their loss, another company’s gain.”
Coz if you’re really got into the last stages of the recruiting-process, you are already a good candidate and should be in a good situation.
Thus, instead of pushing onseself to gain yet more technical skills (like ML-algorithms), I suggest to hone the interpersonal skills.