mirror of
https://github.com/Jaxan/hybrid-ads.git
synced 2025-04-27 23:17:44 +02:00
Adds some options to the learning graph tool
This commit is contained in:
parent
0e2547be86
commit
e392f65658
1 changed files with 21 additions and 7 deletions
|
@ -17,9 +17,12 @@ static const char USAGE[] =
|
||||||
R"(Generate a statistical learning graph from multiple runs
|
R"(Generate a statistical learning graph from multiple runs
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
learning_graph <file> ...
|
learning_graph [options] <file> ...
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
--testing_only Only count the figures for testing
|
||||||
|
--learning_only Only count the figures for learning
|
||||||
|
--accumulate Accumulates the data
|
||||||
-h, --help Show this screen
|
-h, --help Show this screen
|
||||||
--version Show version
|
--version Show version
|
||||||
)";
|
)";
|
||||||
|
@ -73,12 +76,24 @@ void print_quantiles(C const & container, S && selector, ostream & out) {
|
||||||
out << selector(sorted_container.back());
|
out << selector(sorted_container.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto all(datapoint const & p) {
|
||||||
|
return p.learning_queries + p.learning_inputs + p.testing_queries + p.testing_inputs;
|
||||||
|
}
|
||||||
|
auto testing(datapoint const & p) {
|
||||||
|
return p.testing_queries + p.testing_inputs;
|
||||||
|
}
|
||||||
|
auto learning(datapoint const & p) {
|
||||||
|
return p.learning_queries + p.learning_inputs;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
const auto args = docopt::docopt(USAGE, {argv + 1, argv + argc}, true, __DATE__ __TIME__);
|
const auto args = docopt::docopt(USAGE, {argv + 1, argv + argc}, true, __DATE__ __TIME__);
|
||||||
|
|
||||||
|
const auto field = args.at("--testing_only").asBool() ? &testing : args.at("--learning_only").asBool() ? &learning : &all;
|
||||||
|
|
||||||
vector<future<dataset>> dataset_futures;
|
vector<future<dataset>> dataset_futures;
|
||||||
for (auto const & filename : args.at("<file>").asStringList()) {
|
for (auto const & filename : args.at("<file>").asStringList()) {
|
||||||
dataset_futures.emplace_back(async([filename] {
|
dataset_futures.emplace_back(async([filename, &args] {
|
||||||
fstream file(filename);
|
fstream file(filename);
|
||||||
if (!file) throw runtime_error("Could not open file " + filename);
|
if (!file) throw runtime_error("Could not open file " + filename);
|
||||||
|
|
||||||
|
@ -89,6 +104,7 @@ int main(int argc, char * argv[]) {
|
||||||
s.push_back(p);
|
s.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.at("--accumulate").asBool())
|
||||||
accumulate_dataset(s);
|
accumulate_dataset(s);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -143,10 +159,8 @@ int main(int argc, char * argv[]) {
|
||||||
// if we're spot on, update current
|
// if we're spot on, update current
|
||||||
if (it.next->states == state) it.current = it.next;
|
if (it.next->states == state) it.current = it.next;
|
||||||
|
|
||||||
const auto v2 = it.next->learning_queries + it.next->learning_inputs
|
const auto v2 = field(*it.next);
|
||||||
+ it.next->testing_queries + it.next->testing_inputs;
|
const auto v1 = field(*it.current);
|
||||||
const auto v1 = it.current->learning_queries + it.current->learning_inputs
|
|
||||||
+ it.current->testing_queries + it.current->testing_inputs;
|
|
||||||
const auto ratio
|
const auto ratio
|
||||||
= it.next->states == state
|
= it.next->states == state
|
||||||
? 1.0
|
? 1.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue