Understanding a practical example for one-hot encoding

In this section, we will use scikit-learn to generate one-hot encoding for a small dataset. You can find the code at this GitHub link:

https://github.com/jalajthanaki/NLPython/tree/master/ch5/onehotencodingdemo.

You can see the code snippet in Figure 5.63:

Figure 5.63: Pandas and scikit-learn to generate one-hot encoding

You can see the output in Figure 5.64:

Figure 5.64: Output of one-hot encoding

Get Python Natural Language Processing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.