[scikit-learn] Generate data from trained naive bayes

klo uo klonuo at gmail.com
Mon Oct 3 11:08:39 EDT 2016


Thanks Andy,

I can comprehend to the point "...and then sample from these Bernoulli
distributions"

>From the data in `feature_log_prob_`, I would guess it contains single
feature (features mean from the trained data) for each class.
I can see how can I sample from `feature_log_prob_`...


On Mon, Oct 3, 2016 at 3:07 PM, Andreas Mueller <t3kcit at gmail.com> wrote:

> Hi Klo.
> Yes, you could, but as the model is very simple, that's usually not very
> interesting.
> It stores for each label an independent Bernoulli distribution for each
> feature.
> these are stored in feature_log_prob_.
> I would suggest you look at this attribute, rather than sample from the
> distribution.
> To sample from it you would have to exponentiate it and then sample from
> these Bernoulli distributions.
>
> Andy
>
>
> On 10/03/2016 07:30 AM, klo uo wrote:
>
> Hi,
>
> because naive bayes is a generative model, does that mean that I can
> somehow generate data based on trained model?
>
> For example:
>
> clf = BernoulliNB()
> clf.fit(train, labels)
>
> Can I generate data for specific label?
>
>
> Thanks,
> Klo
>
>
> _______________________________________________
> scikit-learn mailing listscikit-learn at python.orghttps://mail.python.org/mailman/listinfo/scikit-learn
>
>
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20161003/36145b07/attachment-0001.html>


More information about the scikit-learn mailing list