title: How to specify the prior probability for scikit-learn's Naive Bayes
body: <p>I'm using the scikit-learn machine learning library (Python) for a machine learning project. One of the algorithms I'm using is the Gaussian Naive Bayes implementation. One of the attributes of the <strong>GaussianNB()</strong> function is the following:</p>
  
  <pre><code>class_prior_ : array, shape (n_classes,)
  </code></pre>
  
  <p>I want to alter the class prior manually since the data I use is very skewed and the recall of one of the classes is very important. By assigning a high prior probability to that class the recall should increase.</p>
  
  <p>However, I can't figure out how to set the attribute correctly. I've read the below topics already but their answers don't work for me.</p>
  
  <p><a href="https://stackoverflow.com/questions/25248583/how-can-the-prior-probabilities-manually-set-for-the-naive-bayes-clf-in-scikit-l">How can the prior probabilities manually set for the Naive Bayes clf in scikit-learn?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/20981374/how-do-i-know-what-priors-im-giving-to-sci-kit-learn-naive-bayes-classifiers">How do I know what prior&#39;s I&#39;m giving to sci-kit learn? (Naive-bayes classifiers.)</a></p>
  
  <p>This is my code:</p>
  
  <pre><code>gnb = GaussianNB()
  gnb.class_prior_ = [0.1, 0.9]
  gnb.fit(data.XTrain, yTrain)
  yPredicted = gnb.predict(data.XTest)
  </code></pre>
  
  <p>I figured this was the correct syntax and I could find out which class belongs to which place in the array by playing with the values but the results remain unchanged. Also no errors were given.</p>
  
  <p>What is the correct way of setting the attributes of the <strong>GaussianNB</strong> algorithm from scikit-learn library?</p>
  
  <p><a href="http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html#sklearn.naive_bayes.GaussianNB" rel="noreferrer">Link to the scikit documentation of GaussianNB</a></p>