I’m trying to prepare data for input to a Decision Tree and Multinomial Naïve Bayes Classifier.
This is what my data looks like (pandas dataframe):
Label Feat1 Feat2 Feat3 Feat4
0 1 3 2 1
1 0 1 1 2
2 2 2 1 1
3 3 3 2 3
I have split the data into dataLabel and dataFeatures.
Prepared dataLabel using dataLabel.ravel()
I need to discretize features so the classifiers treat them as being categorical not numerical.
I’m trying to do this using OneHotEncoder
:
enc = OneHotEncoder()
enc.fit(dataFeatures)
chk = enc.transform(dataFeatures)
from sklearn.naive_bayes import MultinomialNB
mnb = MultinomialNB()
from sklearn import metrics
from sklearn.cross_validation import cross_val_score
scores = cross_val_score(mnb, Y, chk, cv=10, scoring='accuracy')
I get this error: bad input shape (64, 16)
This is the shape of label and input:
dataLabel.shape = 72
chk.shape = 72,16
Why won't the classifier accept the onehotencoded features?
EDIT: Adding how I got dataFeatures
dataFeatures = data[['Accpred', 'Gyrpred', 'Barpred', 'altpred']]
Y = dataLabel.ravel()