almost working
parent
b4f07a0162
commit
6f4343ca94
|
|
@ -329,15 +329,9 @@ HybridValues HybridBayesNet::optimize() const {
|
|||
return gbn.logNormalizationConstant();
|
||||
});
|
||||
|
||||
// Compute unnormalized error term
|
||||
std::vector<DiscreteKey> labels;
|
||||
for (auto &&key : x_map.labels()) {
|
||||
labels.push_back(std::make_pair(key, 2));
|
||||
}
|
||||
|
||||
std::vector<double> errors;
|
||||
x_map.visitWith([this, &errors](const Assignment<Key> &assignment,
|
||||
const VectorValues &mu) {
|
||||
// Compute errors as VectorValues
|
||||
DecisionTree<Key, VectorValues> errorVectors = x_map.apply(
|
||||
[this](const Assignment<Key> &assignment, const VectorValues &mu) {
|
||||
double error = 0.0;
|
||||
for (auto &&f : *this) {
|
||||
if (auto gm = dynamic_pointer_cast<GaussianMixture>(f)) {
|
||||
|
|
@ -352,11 +346,12 @@ HybridValues HybridBayesNet::optimize() const {
|
|||
}
|
||||
}
|
||||
}
|
||||
errors.push_back(error);
|
||||
VectorValues e;
|
||||
e.insert(0, Vector1(error));
|
||||
return e;
|
||||
});
|
||||
|
||||
AlgebraicDecisionTree<Key> errorTree =
|
||||
DecisionTree<Key, double>(labels, errors);
|
||||
AlgebraicDecisionTree<Key> errorTree = DecisionTree<Key, double>(
|
||||
errorVectors, [](const VectorValues &v) { return v[0](0); });
|
||||
|
||||
// Compute model selection term (with help from ADT methods)
|
||||
AlgebraicDecisionTree<Key> model_selection_term =
|
||||
|
|
|
|||
Loading…
Reference in New Issue