This a tremendous post and spot on when it comes to possible contact w/ someone who intends to do you harm. Without going to far off topic w/ Hannah, I thought I'd add a little to this highly informative post.
As I always do, I'll quickly preface this w/ my background. 17 yrs LE w/ last few years as a Major Crimes Det. in one of the largest cities in the country (US). Throughout my career, I've been a certified expert and/or instructor in countless disciplines. Pertaining to this post specifically: firearms, OC/chemical munitions, baton, defensive tactics, non-violent crisis intervention, to name a few. I've also been involved in Martial Arts, Powerlifting, and teaching "self-defense" longer than I've been on the job. I weigh 235lbs w/ 10-12% body fat.
Why did I feel the need to explain all this ? I practice what I preach. ESCAPE ROUTE. Carrying a firearm, pepper spray, trained in any type of the arts, can and will help you. But, this usually is going to require very rare and certain circumstance. Mostly meaning - you need to be prepared at that very moment to be able to apply any of their usages while YOU are in control. Again, always an exception to a rule.
Margarita couldn't have said it any better. It's not always reasonable to travel in pairs/groups. However, even this practice isn't always a deterrent. (Particularly when the offender is under the influence, desperate for money/valuables, has mental health issues). Scan, look at what's ahead and BEYOND. Left to right, behind, etc. I teach people to treat walking in public like they're driving a vehicle. Be aware. Watch for others. Keep eye in rear view. ALWAYS HAVE AN ESCAPE ROUTE. When you stop your vehicle behind another, leave enough distance that you see that persons' rear tires. That's enough distance to "escape". Always back into parking spots. There's much more I can go on about (interview stance, talk w/ your hands, etc.), but again, didn't want to steer too of topic and mostly wanted to commend, and recommend really absorbing the excellent post by margarita.