Can I get into a top school C.S. Ph.D. program with a Master's from a lower ranking university? Is it possible, and what are the chances of doing so, to get into a Computer Science Ph.D. program at a top school like e.g. the U of Toronto with a Master's degree (say, with excellent academic record) from a lower-tier school?

My situation is as follows:


I am about to complete my Master's degree in math (GPA will be between 3.7 and 4.0) in a program with a high reputation (acceptance rate 40 out of 170). I have done mainly (functional) analysis and mathematical physics, and some differential geometry and probability theory. No computer science-related stuff. Also, no statistics (so far at least).
However, I am increasingly unhappy with my field, and I would like to go into machine learning. I know how to program and I have won some competitions as a high school student at federal state level (Germany), but I haven't taken any university courses in computer science so far.
This term I'm taking courses in databases, operating systems and machine learning. That will be enough to get admitted into the Applied Computer Science Master's degree at the University of Heidelberg (note that Master programs in Germany are two-years programs). Certainly not itself a bad university, but the computer science program doesn't really have a very high reputation (after all, there's a reason the admission requirements are so low). With virtually no formal education in computer science, I just don't have a lot of options at the moment.
Assuming that I will complete that Master's program with a very good GPA (and also additionally take the one and the other undergrad course like e.g. algorithm design to catch up), what would be my chances to be admitted e.g. into the Computer Science Ph.D. program at the University of Toronto or a similarly good school? At the moment, I would certainly have no chances to be admitted into their Master's program.


I have also considered doing a one-year computer science conversion Master at a better school, but I found the curricula of those programs rather basic and concluded that doing a 'real' Master's at a not-so-good school would be the better option. But maybe that's just my German way of thinking... Here in Germany the name of your schools means relatively little, but my impression is that things are somewhat different in the anglophone world (in particular the U.S. and the UK).


Would it increase my chances if I combine this degree with edX MOOCs from top-tier schools like MIT?
There are some academic-cultural differences between US (where I live) and Canada, so take my answer with a grain of salt.

Top CS PhD programs in the US are looking primarily for concrete evidence of research potential in PhD applications.  This is especially true in machine learning, which is by far the single most popular research area for PhD appicants.  (At least a third of last year’s PhD applicants at Illinois listed ML or some close variant as their primary research interest.)  I cannot emphasize this enough—competition for PhD programs in ML is incredibly fierce.  ML has become the default area-of-interest for smart people who like CS but don’t really know what they want to do.  High grades and test scores might be enough to get a human being to look at your application, but they will not be enough to get you in; classes ain’t research.

In addition, since you’d be applying with a masters degree, you’ll be compared with other applicants with masters degrees, many of whom will already have ML publications. (Unlike Europe, most PhD programs in North America require only a bachelor’s degree to enroll, and most new PhD students in those programs do not have master’s degrees.)

On the other hand, a strong background in functional analysis, differential geometry, and probability theory is extremely rare among computer scientists, and could be a huge advantage, if you can leverage that expertise into concrete evidence of research potential.

Some specific things to aim for in a master’s program:


When you apply for PhD prorgams, you will need recommendation letters from well-known researchers researchers in your target research area.  Make sure the department where you get your master’s degree has those researchers!  You should be thinking in terms of potential faculty mentors/references, not departments.
In your PhD application, you must be able to talk about your research interests using the idiomatic language of a researcher, not just as an interested student.  Moreover, your recommendation letters must present concrete evidence of your research potential.  Make sure that your masters program gives you an opportunity to do research (or at least indepedent study projects) with those well-known researchers in your target research area.
A purely course-based master’s degree will work against you; classes ain’t research.  Similarly, using MOOCs as evidence of your expertise in ML will work against you, because we only have your word for how well you did, and MOOCs definitely ain’t research.  That doesn’t mean on-campus courses and MOOCs are useless, but you should use them to enable your research, not as end goals in themselves.
Leverage your strengths.  Look for MS programs that will help you develop research expertise that takes advantage of your particular skills.  In particular, look for potential faculty mentors who have, or at least appreciate, a similar mathematics background to your own.
Sadly, the name of your school does matter.  There are too many good applications; people apply all sorts of stupid filters to limit the number of applications they have to read.  (It might matter less coming from Germany, where there’s less variance in quality/reputation.)  Wherever you are offered admission, ask for data about PhD placement before deciding which offer to accept.