18 template<
typename this_t,
21 typename data_t=std::vector<datum_t>,
37 virtual void recompute_P(std::vector<HYP>& hypotheses,
const data_t& human_data) {
38 assert(
which_data == std::addressof(human_data));
40 P.reset(
new Predict_t(hypotheses.size(), human_data.size()));
42 #pragma omp parallel for 43 for(
size_t h=0;h<hypotheses.size();h++) {
47 auto ret = hypotheses[h].call(*human_data[0].predict);
49 for(
size_t di=0;di<human_data.size();di++) {
52 if(di > 0 and (*human_data[di].predict != *human_data[di-1].predict)) {
53 ret = hypotheses[h].call(*human_data[di].predict);
72 std::map<typename HYP::output_t, double> model_predictions;
78 for(
int h=0;h<hposterior.rows();h++) {
79 if(hposterior(h,i) < 1e-6)
continue;
81 for(
const auto& [outcome,outcomelp] :
P->at(h,i)) {
82 model_predictions[outcome] += hposterior(h,i) * exp(outcomelp);
86 return model_predictions;
_Predict_t Predict_t
Definition: BaseGrammarHypothesis.h:58
_HYP HYP
Definition: BaseGrammarHypothesis.h:51
Eigen::MatrixXf Matrix
Definition: EigenLib.h:18
Definition: BaseGrammarHypothesis.h:48
Definition: HumanDatum.h:19
std::shared_ptr< Predict_t > P
Definition: BaseGrammarHypothesis.h:92
Super::Predict_t Predict_t
Definition: FullGrammarHypothesis.h:29
Just a little wrapper to allow vectors to be handled as 2D arrays, which simplifie some stuff in Gram...
Definition: Vector2D.h:14
virtual void recompute_P(std::vector< HYP > &hypotheses, const data_t &human_data)
Recompute the predictions for the hypotheses and data.
Definition: FullGrammarHypothesis.h:37
const data_t * which_data
Definition: BaseGrammarHypothesis.h:99
std::unordered_map< typename datum_t::data_t *, std::vector< Vector > > LL_t
Definition: BaseGrammarHypothesis.h:61
Definition: FullGrammarHypothesis.h:23
virtual std::map< typename HYP::output_t, double > compute_model_predictions(const data_t &human_data, const size_t i, const Matrix &hposterior) const
This uses hposterior (computed via this->compute_normalized_posterior()) to compute the model predict...
Definition: FullGrammarHypothesis.h:70
This class does grammar inference with some collection of HumanData and fixed set of hypotheses...