End-to-End ML Project- Beginner friendly

66 / 95

Attribute combinations

Sometimes, it may be the case that a single attribute is not very useful while prediction. For example, the total number of rooms in a block is not very useful if you don’t know how many households there are. So, in such cases, we create new attributes by combining two or more attributes.

Here, we create three new features, which are-

  1. rooms_per_household - We divide the number of rooms in each block by its household value. It tells us on average how many rooms are there in a particular block per household.

  2. bedrooms_per_room- We divide the number of bedrooms in each block by the number of rooms in that particular block. It tells us the average ratio of the number of bedrooms to the number of rooms in a particular block.

  3. population_per_household - We divide the population of each block by its household value. It will tell us on average how many people live in a particular house in a block.

INSTRUCTIONS

Create the three new features as mentioned above with the same name and append them to our dataset train_copy.

For example, we can create the feature rooms_per_household and append it to our dataset like-

train_copy["rooms_per_household"] = train_copy["total_rooms"]/train_copy["households"]

In the same way, create the other two.



Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...