[scikit-learn] Generate data from trained naive bayes

Manoj Kumar manojkumarsivaraj334 at gmail.com
Mon Oct 3 14:20:09 EDT 2016


Let's say you would like to generate just the first feature of 1000 samples
with label 0.

The distribution of the first feature conditioned on label 1 follows a
Bernoulli distribution (as suggested by the name) with parameter
"exp(feature_log_prob_[0, 0])". You could then generate the first feature
of these 1000 samples by just doing

first_feature = bernoulli.rvs(exp(feature_log_prob_[0, 0]), size=1000)

And follow the same approach for all the other features with the
corresponding parameters. (They are conditionally independent)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20161003/973ad092/attachment.html>


More information about the scikit-learn mailing list