If you can’t avoid a potential problem, it’s much better to act early with confidence, than to cower indecisively hoping it’s not going to happen. Only run when you’re far enough away for them not to catch up with you, as running away is a sign of fear, and fear spurs on predators – whether animal or human.
One unfortunate reality is that a person on their own is especially vulnerable, and they have no witness to say what happened, which experienced trouble-makers, who invariably operate in groups of two and more, know means that police action and criminal charges are unlikely for whatever they might do to you. Also, if you get the better of such people, you are likely to be arrested and charged yourself.
For this reason, most self-defence experts advise taking extreme action, preferably to the extent that your attackers can’t remember what happened, then running from the scene and not reporting the incident to police.
My advice is not to let things get that far, which you can often achieve through a careful mixture of confidence, humour and aggression.