5.1. Exercises
Fit or Predict
Do the following statements correspond to the fit or the predict stage:
First Step in Building a Model
Question 1
Below is the output of y.value_counts().
Position
Forward 13
Defense 7
Goalie 2
dtype: int64
In this scenario, what would a DummyClassifier(strategy='most_frequent') model predict on the observation:
No. Age Height Weight Experience Salary
1 83 34 191 210 11 3200000.0
Building a Model
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.
Letβs start by building a baseline model using DummyClassifier() on the candybars dataset.
Tasks:
- Build a baseline model using
DummyClassifier()andmost_frequentfor thestrategyargument. Save this in an object namedmodel. - Fit your model and then predict on the target column.
- What is the accuracy of the model to 2 decimal places? Save this in the object
accuracy.