That's only because SF isn't safe, esp relative to rent price. I regularly walk alone at 2:30am in nyc in most neighborhoods.
All the deserted streets in Detroit? Not so much.
And note that SF spends $604 on policing per resident, vs NYC's $626 on policing per resident