Depends what sort of ratings you mean.
If you mean the ratings for size of viewing audience they are obtained by "market research" by the Broadcasters' Audience Reasearch Board ( BARB ):
from the self reported viewing history of a "panel" compising a statistically significant representative number of viewers. ( At least that is how it is done here in the UK ).
If you mean the "star" and "numerical" ratings representing the subjective entertainment (and so forth) value of individual programmes - they tend to be done on the basis of professional TV critics opinions and other ad hoc methods (used by individual media publishers) to grade the programmes in order to inform and guide their readers towards those programmes that they perceive to be of higher merit.
Best wishes - Majikthise.
Hi handsome,My name is Layla, i am new to this site looking for a friend i am simple loving caring lady if you don't mind send me a message directly to my email address for us to know each other better,
Usually, independent research agencies will make phone calls to a sample group, usually a good cross-section of people, and simply ask them what they watched.