The only sure way is to restore from your latest backup, which is why Apple added Time Machine for easy use.

If you do not have that then the first thing to do is turn the machine off so that no more data is written to the disk. Then boot the machine off a recovery disk like Diskwarrior. If you are lucky then you can restore data if not the next step would be to send the disk to a specialist and pay them to see what they can get back. If you have a solid state disk then I think you are unlucky and even a specialist will have problems getting data back.