title: How to use One-hot Encode while using NaiveBayes algorithm?
body: <p>I'm trying to use Naive Bayes algorithm for one of my requirements. In this, I have planned to use "One-hot Encode" for hyper plane. I have used the following code for running my algorithm. But, I'm not sure how to use "One-hot Encode". </p>
  
  <p>Please find the below code:</p>
  
  <pre><code>from sklearn.preprocessing import MultiLabelBinarizer
  from sklearn.model_selection import train_test_split
  from sklearn.naive_bayes import BernoulliNB
  from sklearn.metrics import confusion_matrix
  
  def load_data(filename):
  
      x = list()
      y = list()
      with open(filename) as file:
          file.readline()
          for line in file:
              line = line.strip().split(',')
              y.append(line[1])
              x.append(line[0].split())
  
      return x, y
  
  X_train, y_train = load_data('/Users/Desktop/abc/train.csv')
  X_test, y_test = load_data('/Users/Desktop/abc/test.csv')
  
  onehot_enc = MultiLabelBinarizer()
  onehot_enc.fit(X_train)
  
  
  bnbc = BernoulliNB(binarize=None)
  bnbc.fit(onehot_enc.transform(X_train), y_train)
  
  score = bnbc.score(onehot_enc.transform(X_test), y_test)
  print("score of Naive Bayes algo is :" , score)
  </code></pre>
  
  <p>Can anyone please suggest me whether the above written code is correct ?</p>