I think you need to think a bit about what's going to happen over the 4 years:
Are you starting school with student loan debt? That will reduce how much you can borrow in the Federal programs. What will be your tuition? Will you max out the Federal limit before you graduate? Is your car going to be reliable for the next 4 years? How about misc expenses (like USMLE board prep and tests, residency applications and interview expenses etc). What's your school's budget (do you have to take out private loans to meet it?) All these questions are geared to estimating what your financial status will be 3-4 years from now. If any of these questions lead you to think that you'll need money 4 years from now, do not invest it in stocks or mutual funds (or CDs for that matter). Instead, keep it in a high yield savings account. That 4.5% CD seemed great but you can get 4.65% in a savings account with all of that money immediately available. Plus, the Fed is not done raising interest rates so those rates will be going up.
As far as paying the interest before it capitalizes, you can wait until you graduate because that interest accrues without capitalizing until you enter repayment (or consolidate).
Over the last 4 years of school I was 100% invested in stocks. Over that time here are the stocks I lost money on: Dell, Microsoft, JP Morgan, Dupont, SBC, Eastman Kodak. I still managed a 15% annual return because 1 stock doubled. Looking back, that was far too much risk for what I needed that money for. I entered school with 35K in undergrad/grad loans, and had to take 20K in private loans, after maxing the federal. I still needed money for residency interviews, moving, living expenses before residency pay kicks in etc.
So basically, project your financial picture 4 years from now. Chances are you'd rather have that money to live on than have paid down a little bit of accrued interest.