In a "bad" part of town, maybe think of the people there as real people, and don't come across as obviously fearful. This has worked pretty well for me (although there are certainly other factors involved).
Sure on an intellectual level, everyone is a human being, deserves to be heard, not feared, etc, etc.
At night, in a neighborhood ridden with crime, seeing a bunch of teenagers zoom on your from across the street and starting to cross the street toward you, it is easy to re-assess some priorities.
If you look like you'll bolt the moment you're threatened, that's a better outcome. Better than being stabbed or shot, at least.
* walk quickly, don't look lost
* keep your head up
* brief eye contact with people you see/pass
but honestly, 99% of not being accosted is being male, so it's impossible to tell what really works.