In this lesson, we’ll create a decision tree build off of a dataset about cars. When considering buying a car, what factors go into making that decision?
Each car can fall into four different classes which represent how satisfied someone would be with purchasing the car —
Each car has 6 features:
- The price of the car which can be
- The cost of maintaining the car which can be
- The number of doors which can be
- The number of people the car can hold which can be
- The size of the trunk which can be
- The safety rating of the car which can be
We’ve imported a dataset of cars behind the scenes and created a decision tree using that data. In this lesson, you’ll learn how to build that tree yourself, but for now, let’s see what the tree can do!
Create a variable named
car. We’re going to be feeding
tree, the decision tree we’ve made behind the scenes.
car should be a list of six items — one value for each feature.
Try to make is a car that you think would have the label
vgood and we’ll see if the decision tree agrees with you!
Make sure your features are in the order listed above.
tree as parameters. Print the result.
Did the decision tree classify
car as you expected?
Feel free to change the features of
car to see how