Although you're no more likely to be a victim of crime on public transport as you are anywhere else, there are a few simple actions you can take to make sure you stay safe:
On the bus
use a bus stop you know, or one that appears busy and well lit
if you're going to an unfamiliar place, have friends meet you at your destination
sit close to the driver
On the train
wait on a well lit section of platform, near other people
sit in a busy compartment at the front of the train
if you feel uncomfortable, consider getting out of your carriage and into another, or even getting off the train altogether
On the tube
sit in a carriage near the front of the train
if anybody makes you feel uncomfortable, get off and wait for the next tube
late at night, have friends or family meet you at your destination station
Taking a taxi
as often as possible, use a taxi company you know, or one recommended by family or friends
if you have booked a taxi over the phone, make sure the driver knows your name and destination, in order to ensure it's the correct taxi
have your money and keys ready so that you can get into your home quickly at the end of your journey
if you feel uncomfortable in a taxi, ask the driver to stop in a busy familiar place and get out of the car