Unrelated project during PhD
Long story short: Depends. It is difficult to answer these questions without understanding the precise details of your situation. Getting experience is always a good thing, especially if it is programming experience, and you are considering a possible career shift towards more programming/machine learning heavy field of research . However, your part-time contribution to a different scientific project might distract you from finishing your PhD: which should be, considering the year you are in your main worry. If possible, I would discuss this with your supervisor and ask them for a honest opinion: if they feel like your particular situation (expected time commitment, skills, the nature of the work...) allows to go for outside research opportunity, and they think it is good for your career, good for you. I believe that simply bringing up the subject is very unlikely to upset them: after all, their main purpose, at least from your point of view is to supervise you and advise you on starting of your scientific career. If however they express doubts about the extra project being a good fit for you at this point, you might consider focusing on your PhD and then looking for extra learning opportunities: remember that life is just starting after you're done, and there will be plenty of time for various projects afterwards. As to whether the experience would count: depends on what do you understand as 'counts'. But personally I believe that at least familiarity with programming is a skill which counts a lot regardless of the field you end up with.