Add comments to BoostAODE algorithm

This commit is contained in:
Ricardo Montañana Gómez 2024-02-19 22:58:15 +01:00
parent f3b8150e2c
commit c7555dac3f
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
5 changed files with 11 additions and 5 deletions

BIN
docs/BoostAODE.docx Normal file

Binary file not shown.

1
lib/argparse Submodule

@ -0,0 +1 @@
Subproject commit 69dabd88a8e6680b1a1a18397eb3e165e4019ce6

@ -1 +1 @@
Subproject commit 863c662c0eff026300f4d729a7054e90d6d12cdd
Subproject commit 766541d12d64845f5232a1ce4e34a85e83506b09

1
lib/libxlsxwriter Submodule

@ -0,0 +1 @@
Subproject commit 29355a0887475488c7cc470ad43cc867fcfa92e2

View File

@ -121,6 +121,8 @@ namespace bayesnet {
}
void BoostAODE::trainModel(const torch::Tensor& weights)
{
// Algorithm based on the adaboost algorithm for classification
// as explained in Ensemble methods (Zhi-Hua Zhou, 2012)
std::unordered_set<int> featuresUsed;
if (selectFeatures) {
featuresUsed = initializeModels();
@ -132,9 +134,8 @@ namespace bayesnet {
// Variables to control the accuracy finish condition
double priorAccuracy = 0.0;
double delta = 1.0;
double threshold = 1e-4;
int count = 0; // number of times the accuracy is lower than the threshold
fitted = true; // to enable predict
double convergence_threshold = 1e-4;
int count = 0; // number of times the accuracy is lower than the convergence_threshold
// Step 0: Set the finish condition
// if not repeatSparent a finish condition is run out of features
// n_models == maxModels
@ -191,10 +192,12 @@ namespace bayesnet {
} else {
delta = accuracy - priorAccuracy;
}
if (delta < threshold) {
if (delta < convergence_threshold) {
count++;
}
priorAccuracy = accuracy;
}
// epsilon_t > 0.5 => inverse the weights policy (plot ln(wt))
exitCondition = n_models >= maxModels && repeatSparent || epsilon_t > 0.5 || count > tolerance;
}
if (featuresUsed.size() != features.size()) {
@ -202,6 +205,7 @@ namespace bayesnet {
status = WARNING;
}
notes.push_back("Number of models: " + std::to_string(n_models));
fitted = true;
}
std::vector<std::string> BoostAODE::graph(const std::string& title) const
{