Question: Now, let s use scikit - learn to train a DecisionTreeClassifier and KNeighborsClassifier on the data. Using the predictive capabilities of the scikit - learn

Now, lets use scikit-learn to train a DecisionTreeClassifier and KNeighborsClassifier on
the data.
Using the predictive capabilities of the scikit-learn package is very simple. In fact, it can be
carried out in three simple steps: initializing the model, fitting it to the training data, and predicting
new values.1
(b)(0 pts) Before trying out any classifier, it is often useful to establish a baseline. We have
implemented one simple baseline classifier, MajorityVoteClassifier, that always predicts
the majority class from the training set. Read through the MajorityVoteClassifier and
its usage and make sure you understand how it works.
Your goal is to implement and evaluate another baseline classifier, RandomClassifier, that
predicts a target class according to the distribution of classes in the training data set. For
example, if 85% of the examples in the training set have >50k =0 and 15% have >50k =1,
then, when applied to a test set, RandomClassifier should randomly predict 85% of the
examples as >50k =0 and 15% as >50k =1.
Implement the missing portions of RandomClassifier according to the provided specifications.
Then train your RandomClassifier on the entire training data set, and evaluate its
training error. If you implemented everything correctly, you should have an error of 0.374
or 0.385.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!