Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do the following steps: Create testBrnli by 0 - 1 encoding testy variable Transform testX into pandas data frame by with encoded values of all

Do the following steps:
Create testBrnli by 0-1 encoding testy variable
Transform testX into pandas data frame by with encoded values of all the features. The transformed data frame should still be called testX.
Create vector (i.e. numpy arrray) of predictions, called yhattest, based on the feature values from the test data.
If everything is fine, first couple of values of yhattest should be 1,0,0,1,1,0,0,1,0.
est
# your code here
from sklearn.preprocessing import LabelEncoder, OrdinalEncoder
from sklearn.naive_bayes import CategoricalNB
enc = OrdinalEncoder()
le = LabelEncoder()
testBrnli = le.fit_transform(testy)
testX = pd.DataFrame(testX, columns=colnames)
model = CategoricalNB()
model.fit(testX, testBrnli)
yhattest = model.predict(testX)
yhattest[:9]

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

Step: 3

blur-text-image

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 Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

How do i calculate the beta?

Answered: 1 week ago

Question

Roll out international HRM practices for franchisees.

Answered: 1 week ago