The ratings are stored in the iTunes Library file. It's located in (home folder)/Music/iTunes. If you delete and reinstall your music library without restoring that file, your ratings will be lost.
In future, if you need to do a backup/restore of iTunes, be sure to grab the *entire* iTunes folder, not just the iTunes Music folder.