When I rode through some mildly gang-infested parts of a city, I wore a Sherlock Holmes style deerstalker hat. The boys would call out stuff lie 'Oi Sherlock". I think being weird in a harmless sort of way defuses tension and reduces the challenge they perceive to their turf.
If you do decide to ride through potentially dangerous areas, get the most puncture-resistant tyres you can find.