The numbers are a pure statistical extrapolation. Viewing is measured using cable set top boxes. Nielsen already knows who is in the HH and who is watching. By who, I mean their demographic information..age, sex, etc. The "box" records who and when and channel viewing takes place. Also the viewing has to take place for at least 5 minutes inside a quarter hour.
The # is mathematically extrapulated from that information at the "box" level. If 500 HH are watching a show for at least 5 minutes between 730p and 745p, then that viewing number is figured using a formula representing all cable tv HH. If 500 HH are viewing this program and there are 1 million sets in use, how many HH are then viewing the program. Demo # are derived the same way.
There are other factors and viewing standards involved, but that is the basic meat and potatoes of how this works.