What are the academic career prospects for someone in their late 30's starting a PhD?
I think the answer here is that it depends on a lot of factors, but that you'll generally do better in the Machine Learning field than you would in many of the older, more established fields.
For starters, there's just not that many people out there with PhDs in Machine Learning. I'm an economist, but I've spent a lot of time working around the edges of machine learning and data science. Many of the faculty in that area have degrees in different but related fields. Econ, stats, math, and computer science are common.
Machine learning is also an incredibly hot field right now. Before I went back to academia I worked in applied research, and finding an experienced person with a "data scientist" title in their job history was a nightmare. Private sector jobs are common, and the salaries are high, which pulls people away from academia.
So while being an older graduate hitting the job market may be a challenge in academia, I think the shortage of talent available in this field will offset it. Especially if you have relevant work experience in data science, research, and/or machine learning from before now.
On a side note, unless your goal is specifically to do PhD research (i.e. are you interested in applying ML in teaching or research, or are you interested in working on the mathematical underpinnings?) in the field and earn tenure, you can accomplish a lot, even in academia, with a master's degree in this field. Might be something to explore if you decide not to go the whole way.
A slightly utopian answer, but I’ll wait for all the naysayers out there to correct me if they want to:
Your academic career prospects as a beginning graduate student in your late 30’s are the same as they would be for a beginning graduate student of any other age group.
If you are talented and work hard, you will succeed. Don’t overthink this.
In addition to that, your area is super trendy and I’m hearing about a lot of hiring activity currently going on in this and related areas (anything that falls under the label of data science). So your prospects seem generally good, both in academia and (perhaps even more so) in industry.
Good luck!
Your age is not the thing you should be worrying about. You only have one life and you should be working to live it as you find comfortable, pleasurable, useful, ...
The particular field you think you want to enter now should also be a secondary concern in terms of its "hotness". Whether it actually interests you and you feel it is worth pursuing is a much more important consideration. Your chosen field, whatever it is, will probably have a different "hotness index" when you finish than when you start.
You will be older in a few years whether you do the doctorate or not. If you don't, then where will you be in your life's plan. My former spouse finished a doctorate at about 40 and went on to a nice career. And, of course, a decision made now can be altered somewhere along the line as things, including your own needs, change.
Whether you need to spend time in a post-doc depends on a lot of things. Many people do now-a-days, but a lot of that is just the job market. If it takes you a few years to earn the doctorate then the market is highly likely to be different when you finish than when you start. Unfortunately you can't say whether it will be better or worse then, but that would be true if you were 20, now.
And being on the tenure track in the US (an assistant professor) is really being a professor. You just don't have quite the same job security as a tenured person, but the job is really just the same: Teaching, Research, Service in some proportion depending on the institution.
So, my best advice is to do what most appeals to your sense of self-worth.