I am using the scikit-learn machine learning library (Python) for a machine learning project. One of the algorithms that I use is the implementation of Gaussian Naive Bayes. One of the attributes of the GaussianNB () function is the following:
class_prior_ : array, shape (n_classes,)
I want to change the class earlier manually, because the data that I use is very distorted, and recalling one of the classes is very important. When assigning a high probability for this class, the recall should increase.
However, I cannot figure out how to set the attribute correctly. I already read the topics below, but their answers do not work for me.
How can I set previous probabilities for Naive Bayes clf in scikit-learn?
How do I know that earlier I let sci-kit learn? (Classifiers of naive bays.)
This is my code:
gnb = GaussianNB() gnb.class_prior_ = [0.1, 0.9] gnb.fit(data.XTrain, yTrain) yPredicted = gnb.predict(data.XTest)
I realized that this was the correct syntax, and I could find out which class belongs to that place in the array, playing with the values, but the results remain unchanged. There were also no errors.
What is the correct way to set attributes of the GaussianNB algorithm from the scikit-learn library?
Scikit GaussianNB documentation link
python syntax scikit-learn machine-learning
pevadi
source share