Exercise

Encoding techniques

In the slides, we discussed two encoding techniques: label encoding and one-hot encoding. In practice, the technique that you use is determined by the situation at hand. That being said, you should have both of these at your disposal for your interview.

In this exercise, you'll practice implementing both of these techniques on the same dataset of laptop prices that you saw earlier, pre-loaded within the laptops variable.

Instructions 1/2

undefined XP
  • 1

    Use the created label encoder object in encoder to transform the Company column; print the results.

  • 2

    One-hot encode laptops2 copied from our original DataFrame on the Company column; print the head of the DataFrame.