Question: 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
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

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!