Preheat your oven to 350°F (175°C). Lightly grease an 8-inch springform pan and line the bottom with parchment paper.
In a bowl, whisk together flour, baking soda, baking powder, cinnamon, nutmeg, and salt.
In another bowl, mix oil, granulated sugar, brown sugar, egg, and vanilla until smooth. Stir in the grated carrots and walnuts if using. Gradually fold in the dry ingredients until just combined. Spread this carrot cake batter evenly into the prepared pan.
In a separate bowl, beat the cream cheese until smooth. Add sugar and mix until creamy. Beat in the eggs one at a time. Stir in vanilla and sour cream until fully combined and silky.
Pour the cheesecake mixture gently over the carrot cake batter, smoothing the top carefully.
Bake for 50–60 minutes, or until the center is slightly set but still has a small jiggle. Turn off the oven, crack the door slightly, and let it cool inside for 1 hour to prevent cracking.
Remove from the oven and refrigerate for at least 4 hours or overnight.
For the frosting, beat cream cheese and butter until smooth. Add powdered sugar and vanilla, and mix until fluffy. Spread lightly on top before serving if desired.