Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions