4.1. Exercises
Terminology
Candybars
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line wonβt execute and you can test your code after each step.
Describing a Dataset
Letβs make sure we understand all the components we use in a dataset for machine learning. The packages you need will be loaded for you. In this example we would be attempting to predict the country availability of candy bars, which makes the column availability the target.
Task:
- Save the dimensions of the dataframe in an object named
candybar_dim.
Separating Our Data
Letβs split up our the data in the candybars dataframe into our features and target. For this dataframe the features are the columns chocolate to multi and the target is the column availability.
Task 1:
- Save the columns
chocolatetomultiin an object namedX.
Task 2:
- Since we are attempting to predict the country availability of candy bars, make the column
availabilitythe target and name the objecty.