How to obtain a fair recommendation letter from a professor who knows me via course, not research?
Visit the professor and explain your plans and your wish to have him provide a letter in a brief but structured way. Slip in some of your (positive) thoughts concerning his course and, if you were inspired by it, the importance of the course for your current interest. I do not think you can do more. If the person is not interested, I doubt you can do anything to change the view that would not be annoying in the end. It is possible the person has forgotten you but if you stood out even a little in the class, my bet would be the opposite. As I see it you only risk getting a no, and not much could be done to change that.