6 class MyHypothesis :
public Lexicon<MyHypothesis, std::string, InnerHypothesis, BindingTree*, std::string> {
21 f.program.loader =
this;
24 for(
auto& [k, f] : factors) {
38 for(
size_t di=0;di<data.size();di++) {
46 for(
const auto& w :
words) {
48 auto b = factors[w].cache.at(di);
63 likelihood += (double(
NDATA)/double(data.size())) * log( (wtrue ? d.reliability/ntrue : 0.0) +
64 (1.0-d.reliability)/words.size());
74 virtual void show(std::string prefix=
"")
override {
89 for(
auto& w :
words) {
93 for(
size_t di=0;di<target_precisionrecall_data.size();di++) {
102 COUT float(nagree)/float(ntot) TAB
"";
A lexicon stores an association of numbers (in a vector) to some other kind of hypotheses (typically ...
std::string QQ(const std::string &x)
Definition: Strings.h:190
double likelihood
Definition: Bayesable.h:42
OrderedLock output_lock
Definition: IO.h:31
virtual double compute_posterior(const data_t &data, const std::pair< double, double > breakoutpair=std::make_pair(-infinity, 1.0))
Compute the posterior, by calling prior and likelihood. This includes only a little bit of fanciness...
Definition: Bayesable.h:134
#define TAB
Definition: IO.h:19
double prior
Definition: Bayesable.h:41
int NDATA
Definition: Main.cpp:21
void clear_cache()
Definition: MyHypothesis.h:12
double posterior
Definition: Bayesable.h:43
we don't need inputs/outputs for out MyHypothesis
Definition: MyHypothesis.h:6
virtual void show(std::string prefix="") override
Definition: MyHypothesis.h:74
constexpr double infinity
Definition: Numerics.h:20
MyHypothesis target
Definition: Main.cpp:55
std::map< key_t, InnerHypothesis > factors
Definition: Lexicon.h:44
double compute_likelihood(const data_t &data, const double breakout=-infinity) override
Compute the likelihood of a collection of data, by calling compute_single_likelihood on each...
Definition: MyHypothesis.h:18
#define ENDL
Definition: IO.h:21
std::vector< Args... > data_t
Definition: Bayesable.h:38
#define COUT
Definition: IO.h:24
const std::vector< std::string > words
Definition: Main.cpp:15
Definition: LRUCache.h:19