14 template<
typename this_t,
17 typename data_t=std::vector<datum_t>,
34 virtual void recompute_P(std::vector<HYP>& hypotheses,
const data_t& human_data)
override {
35 assert(this->
which_data == std::addressof(human_data));
37 this->
P.reset(
new Predict_t(hypotheses.size(), human_data.size()));
38 if(human_data.size() == 0)
return ;
40 #pragma omp parallel for 41 for(
size_t h=0;h<hypotheses.size();h++) {
45 auto ret = hypotheses[h].call(*human_data[0].predict);
47 for(
size_t di=0;di<human_data.size();di++) {
50 if(di > 0 and (*human_data[di].predict != *human_data[di-1].predict)) {
51 ret = hypotheses[h].call(*human_data[di].predict);
55 this->
P->set(h,di,ret);
63 std::map<typename HYP::output_t, double> model_predictions;
65 for(
int h=0;h<hposterior.rows();h++) {
66 if(hposterior(h,i) < 1e-6)
continue;
68 model_predictions[this->
P->get(h,i)] += hposterior(h,i);
71 return model_predictions;
Definition: DeterministicGrammarHypothesis.h:19
virtual void set_hypotheses_and_data(std::vector< HYP > &hypotheses, const data_t &human_data)
This is the primary function for setting hypothese and data on construction.
Definition: BaseGrammarHypothesis.h:172
_Predict_t Predict_t
Definition: BaseGrammarHypothesis.h:58
Eigen::MatrixXf Matrix
Definition: EigenLib.h:18
Definition: BaseGrammarHypothesis.h:48
we don't need inputs/outputs for out MyHypothesis
Definition: MyHypothesis.h:6
virtual void recompute_P(std::vector< HYP > &hypotheses, const data_t &human_data) override
Recompute the predictions for the hypotheses and data.
Definition: DeterministicGrammarHypothesis.h:34
Definition: HumanDatum.h:19
virtual std::map< typename HYP::output_t, double > compute_model_predictions(const data_t &human_data, const size_t i, const Matrix &hposterior) const override
This uses hposterior (computed via this->compute_normalized_posterior()) to compute the model predict...
Definition: DeterministicGrammarHypothesis.h:61
std::shared_ptr< Predict_t > P
Definition: BaseGrammarHypothesis.h:92
Just a little wrapper to allow vectors to be handled as 2D arrays, which simplifie some stuff in Gram...
Definition: Vector2D.h:14
DeterministicGrammarHypothesis(std::vector< HYP > &hypotheses, const data_t *human_data)
Definition: DeterministicGrammarHypothesis.h:29
const data_t * which_data
Definition: BaseGrammarHypothesis.h:99
std::unordered_map< typename HumanDatum< MyHypothesis > ::std::vector< HumanDatum< MyHypothesis > > *, std::vector< Vector > > LL_t
Definition: BaseGrammarHypothesis.h:61
Super::Predict_t Predict_t
Definition: DeterministicGrammarHypothesis.h:25
This class does grammar inference with some collection of HumanData and fixed set of hypotheses...