learning-it by example

#100 AI security and governance 5.2 min

Fake but Realistic Test Data in Python With Faker

A quick comma-split loader failed on all 200 rows of realistic fake customers.

1. The video gives test data two jobs. What are they?
2. Faker made 200 customers with four different email calls. Which calls put all 200 addresses on reserved example domains?
3. Why does the date of birth column change from day to day, even with the same seed?
4. Why did the quick loader get all 200 realistic rows wrong?
5. Why does the video tell you to pin the Faker version?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. Predict a changed seed

    Copy the code folder first. This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In people.py change the default seed=7 in make() to seed=8, then run compare.py. In compare.py the other seed passed in is also 8. Predict what the first line says about the other seed differing, and why. Write your prediction down, then run it.

    A hint

    Look at what the first line compares: make(COUNT, seed=8) and make(COUNT).

  2. Predict a smaller set

    This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In compare.py change COUNT from 200 to 20. Predict what the four email lines say about reserved domains, and what the quick loader line says. Write your predictions down, then run compare.py and see whether the pattern from the video still holds.

    A hint

    The safe calls should stay on reserved domains. Think about what the other two calls do.

  3. Avoid commas in the address

    This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In people.py change .replace('\n', ', ') to .replace('\n', '; ') so the address has no comma from that line break. Predict how many rows the quick loader now gets wrong, then run compare.py. Compare with the 200 of 200 in the video.

    A hint

    Some other part of a fake address or name might still contain a comma.

  4. Try another locale

    This needs Faker, as in the video, and I could not run it, so treat it as a prediction. In people.py change Faker('en_GB') to Faker('de_DE'). Predict which printed lines will change and which will not, especially the reserved domain lines and the apostrophe or hyphen count. Write your prediction down, then run compare.py. The video tested only one locale.

    A hint

    Names and addresses change with the locale. Think about what the email calls look at.

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

200 made-up customers from one library (Faker 40.41.0), one locale (en_GB) and one seed; only four email calls tested; the date of birth depends on the day you run it; fake rows are not the shape of your real data.

Up next in AI security and governance

More in AI security and governance

All AI security and governance videos

Related videos