Return File Library to /lib as it is needed by Local Discretization (factorize)

This commit is contained in:
Ricardo Montañana Gómez 2024-04-30 20:31:14 +02:00
parent 7aeffba740
commit 618a1e539c
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
148 changed files with 1804 additions and 1769 deletions

View File

@ -15,8 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Internal
- Refactor library ArffFile to limit the number of samples with a parameter.
- Refactor tests libraries location to test/lib
- Create library ShuffleArffFile to limit the number of samples with a parameter and shuffle them.
- Refactor catch2 library location to test/lib
- Refactor loadDataset function in tests.
- Remove conditionalEdgeWeights method in BayesMetrics.

View File

@ -60,8 +60,9 @@ endif (ENABLE_CLANG_TIDY)
# External libraries - dependencies of BayesNet
# ---------------------------------------------
# include(FetchContent)
add_git_submodule("lib/mdlp")
add_git_submodule("lib/json")
add_git_submodule("lib/mdlp")
add_subdirectory("lib/Files")
# Subdirectories
# --------------
@ -73,7 +74,6 @@ add_subdirectory(bayesnet)
if (ENABLE_TESTING)
MESSAGE("Testing enabled")
add_subdirectory(tests/lib/catch2)
add_subdirectory(tests/lib/Files)
include(CTest)
add_subdirectory(tests)
endif (ENABLE_TESTING)

35
boostAODE.log Normal file
View File

@ -0,0 +1,35 @@
File verbosity level: 9
date time ( uptime ) [ thread name/id ] file:line v|
2024-04-30 20:24:40.507 ( 0.002s) [BoostAODE ] loguru.cpp:825 INFO| Logging to 'boostAODE.log', mode: 'w', verbosity: 9
2024-04-30 20:24:40.517 ( 0.011s) [BoostAODE ] BoostAODE.cc:321 1| { counter=0 k=1 featureSelection.size: 4
2024-04-30 20:24:40.531 ( 0.025s) [BoostAODE ] BoostAODE.cc:340 2| . { numItemsPack: 1 n_models: 1 featuresUsed: 1
2024-04-30 20:24:40.531 ( 0.025s) [BoostAODE ] BoostAODE.cc:340 2| . } 0.000 s: numItemsPack: 1 n_models: 1 featuresUsed: 1
2024-04-30 20:24:40.533 ( 0.028s) [BoostAODE ] BoostAODE.cc:357 3| . { * (improvement>=threshold) Reset. tolerance: 0 numItemsPack: 1 improvement: 1.000000 prior: 0.933333 current: 0.933333
2024-04-30 20:24:40.533 ( 0.028s) [BoostAODE ] BoostAODE.cc:357 3| . } 0.000 s: * (improvement>=threshold) Reset. tolerance: 0 numItemsPack: 1 improvement: 1.000000 prior: 0.933333 current: 0.933333
2024-04-30 20:24:40.533 ( 0.028s) [BoostAODE ] BoostAODE.cc:369 1| . { tolerance: 0 featuresUsed.size: 1 features.size: 4
2024-04-30 20:24:40.533 ( 0.028s) [BoostAODE ] BoostAODE.cc:369 1| . } 0.000 s: tolerance: 0 featuresUsed.size: 1 features.size: 4
2024-04-30 20:24:40.533 ( 0.028s) [BoostAODE ] BoostAODE.cc:321 1| } 0.016 s: counter=0 k=1 featureSelection.size: 4
2024-04-30 20:24:40.534 ( 0.029s) [BoostAODE ] BoostAODE.cc:321 1| { counter=0 k=1 featureSelection.size: 3
2024-04-30 20:24:40.546 ( 0.040s) [BoostAODE ] BoostAODE.cc:340 2| . { numItemsPack: 1 n_models: 2 featuresUsed: 2
2024-04-30 20:24:40.546 ( 0.040s) [BoostAODE ] BoostAODE.cc:340 2| . } 0.000 s: numItemsPack: 1 n_models: 2 featuresUsed: 2
2024-04-30 20:24:40.549 ( 0.044s) [BoostAODE ] BoostAODE.cc:357 3| . { * (improvement>=threshold) Reset. tolerance: 0 numItemsPack: 1 improvement: 0.033333 prior: 0.933333 current: 0.966667
2024-04-30 20:24:40.549 ( 0.044s) [BoostAODE ] BoostAODE.cc:357 3| . } 0.000 s: * (improvement>=threshold) Reset. tolerance: 0 numItemsPack: 1 improvement: 0.033333 prior: 0.933333 current: 0.966667
2024-04-30 20:24:40.549 ( 0.044s) [BoostAODE ] BoostAODE.cc:369 1| . { tolerance: 0 featuresUsed.size: 2 features.size: 4
2024-04-30 20:24:40.549 ( 0.044s) [BoostAODE ] BoostAODE.cc:369 1| . } 0.000 s: tolerance: 0 featuresUsed.size: 2 features.size: 4
2024-04-30 20:24:40.549 ( 0.044s) [BoostAODE ] BoostAODE.cc:321 1| } 0.015 s: counter=0 k=1 featureSelection.size: 3
2024-04-30 20:24:40.551 ( 0.045s) [BoostAODE ] BoostAODE.cc:321 1| { counter=0 k=1 featureSelection.size: 2
2024-04-30 20:24:40.563 ( 0.058s) [BoostAODE ] BoostAODE.cc:340 2| . { numItemsPack: 1 n_models: 3 featuresUsed: 3
2024-04-30 20:24:40.563 ( 0.058s) [BoostAODE ] BoostAODE.cc:340 2| . } 0.000 s: numItemsPack: 1 n_models: 3 featuresUsed: 3
2024-04-30 20:24:40.568 ( 0.063s) [BoostAODE ] BoostAODE.cc:354 3| . { (improvement<threshold) tolerance: 0 numItemsPack: 1 improvement: -0.033333 prior: 0.966667 current: 0.933333
2024-04-30 20:24:40.568 ( 0.063s) [BoostAODE ] BoostAODE.cc:354 3| . } 0.000 s: (improvement<threshold) tolerance: 0 numItemsPack: 1 improvement: -0.033333 prior: 0.966667 current: 0.933333
2024-04-30 20:24:40.568 ( 0.063s) [BoostAODE ] BoostAODE.cc:369 1| . { tolerance: 1 featuresUsed.size: 3 features.size: 4
2024-04-30 20:24:40.568 ( 0.063s) [BoostAODE ] BoostAODE.cc:369 1| . } 0.000 s: tolerance: 1 featuresUsed.size: 3 features.size: 4
2024-04-30 20:24:40.568 ( 0.063s) [BoostAODE ] BoostAODE.cc:321 1| } 0.018 s: counter=0 k=1 featureSelection.size: 2
2024-04-30 20:24:40.570 ( 0.065s) [BoostAODE ] BoostAODE.cc:321 1| { counter=0 k=2 featureSelection.size: 1
2024-04-30 20:24:40.584 ( 0.079s) [BoostAODE ] BoostAODE.cc:340 2| . { numItemsPack: 2 n_models: 4 featuresUsed: 4
2024-04-30 20:24:40.584 ( 0.079s) [BoostAODE ] BoostAODE.cc:340 2| . } 0.000 s: numItemsPack: 2 n_models: 4 featuresUsed: 4
2024-04-30 20:24:40.590 ( 0.084s) [BoostAODE ] BoostAODE.cc:354 3| . { (improvement<threshold) tolerance: 1 numItemsPack: 2 improvement: 0.000000 prior: 0.933333 current: 0.933333
2024-04-30 20:24:40.590 ( 0.084s) [BoostAODE ] BoostAODE.cc:354 3| . } 0.000 s: (improvement<threshold) tolerance: 1 numItemsPack: 2 improvement: 0.000000 prior: 0.933333 current: 0.933333
2024-04-30 20:24:40.590 ( 0.084s) [BoostAODE ] BoostAODE.cc:369 1| . { tolerance: 2 featuresUsed.size: 4 features.size: 4
2024-04-30 20:24:40.590 ( 0.084s) [BoostAODE ] BoostAODE.cc:369 1| . } 0.000 s: tolerance: 2 featuresUsed.size: 4 features.size: 4
2024-04-30 20:24:40.590 ( 0.084s) [BoostAODE ] BoostAODE.cc:321 1| } 0.020 s: counter=0 k=2 featureSelection.size: 1

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="BaseClassifier.h.gcov.html#L19">bayesnet::BaseClassifier::~BaseClassifier()</a></td>
<td class="coverFnHi">1818</td>
<td class="coverFnHi">606</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="BaseClassifier.h.gcov.html#L19">bayesnet::BaseClassifier::~BaseClassifier()</a></td>
<td class="coverFnHi">1818</td>
<td class="coverFnHi">606</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -80,7 +80,7 @@
<span id="L18"><span class="lineNum"> 18</span> : virtual BaseClassifier&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) = 0;</span>
<span id="L19"><span class="lineNum"> 19</span> : virtual BaseClassifier&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) = 0;</span>
<span id="L20"><span class="lineNum"> 20</span> : virtual BaseClassifier&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; weights) = 0;</span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC tlaBgGNC"> 1818 : virtual ~BaseClassifier() = default;</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC tlaBgGNC"> 606 : virtual ~BaseClassifier() = default;</span></span>
<span id="L22"><span class="lineNum"> 22</span> : torch::Tensor virtual predict(torch::Tensor&amp; X) = 0;</span>
<span id="L23"><span class="lineNum"> 23</span> : std::vector&lt;int&gt; virtual predict(std::vector&lt;std::vector&lt;int &gt;&gt;&amp; X) = 0;</span>
<span id="L24"><span class="lineNum"> 24</span> : torch::Tensor virtual predict_proba(torch::Tensor&amp; X) = 0;</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,168 +65,168 @@
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">bayesnet::Classifier::dump_cpt[abi:cxx11]() const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L178">bayesnet::Classifier::topological_order[abi:cxx11]()</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">bayesnet::Classifier::predict(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">bayesnet::Classifier::getNumberOfStates() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">bayesnet::Classifier::show[abi:cxx11]() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">bayesnet::Classifier::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">126</td>
<td class="coverFnHi">42</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">168</td>
<td class="coverFnHi">56</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">180</td>
<td class="coverFnHi">60</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">bayesnet::Classifier::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">192</td>
<td class="coverFnHi">64</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">bayesnet::Classifier::getNumberOfEdges() const</a></td>
<td class="coverFnHi">282</td>
<td class="coverFnHi">94</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">bayesnet::Classifier::getNumberOfNodes() const</a></td>
<td class="coverFnHi">282</td>
<td class="coverFnHi">94</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">bayesnet::Classifier::predict_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">390</td>
<td class="coverFnHi">130</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">bayesnet::Classifier::buildDataset(at::Tensor&amp;)</a></td>
<td class="coverFnHi">486</td>
<td class="coverFnHi">162</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">bayesnet::Classifier::getClassNumStates() const</a></td>
<td class="coverFnHi">510</td>
<td class="coverFnHi">170</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">594</td>
<td class="coverFnHi">198</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">990</td>
<td class="coverFnHi">330</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">bayesnet::Classifier::addNodes()</a></td>
<td class="coverFnHi">1680</td>
<td class="coverFnHi">560</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L42">bayesnet::Classifier::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1680</td>
<td class="coverFnHi">560</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">bayesnet::Classifier::build(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1932</td>
<td class="coverFnHi">644</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">bayesnet::Classifier::checkFitParameters()</a></td>
<td class="coverFnHi">1932</td>
<td class="coverFnHi">644</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">bayesnet::Classifier::predict_proba(at::Tensor&amp;)</a></td>
<td class="coverFnHi">2226</td>
<td class="coverFnHi">742</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">bayesnet::Classifier::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">2550</td>
<td class="coverFnHi">850</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">bayesnet::Classifier::Classifier(bayesnet::Network)</a></td>
<td class="coverFnHi">2658</td>
<td class="coverFnHi">886</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,168 +65,168 @@
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L10">bayesnet::Classifier::Classifier(bayesnet::Network)</a></td>
<td class="coverFnHi">2658</td>
<td class="coverFnHi">886</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L153">bayesnet::Classifier::addNodes()</a></td>
<td class="coverFnHi">1680</td>
<td class="coverFnHi">560</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L12">bayesnet::Classifier::build(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1932</td>
<td class="coverFnHi">644</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L28">bayesnet::Classifier::buildDataset(at::Tensor&amp;)</a></td>
<td class="coverFnHi">486</td>
<td class="coverFnHi">162</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L77">bayesnet::Classifier::checkFitParameters()</a></td>
<td class="coverFnHi">1932</td>
<td class="coverFnHi">644</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L182">bayesnet::Classifier::dump_cpt[abi:cxx11]() const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L47">bayesnet::Classifier::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">192</td>
<td class="coverFnHi">64</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L66">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">594</td>
<td class="coverFnHi">198</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L72">bayesnet::Classifier::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">990</td>
<td class="coverFnHi">330</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L55">bayesnet::Classifier::fit(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">180</td>
<td class="coverFnHi">60</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L174">bayesnet::Classifier::getClassNumStates() const</a></td>
<td class="coverFnHi">510</td>
<td class="coverFnHi">170</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L166">bayesnet::Classifier::getNumberOfEdges() const</a></td>
<td class="coverFnHi">282</td>
<td class="coverFnHi">94</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L161">bayesnet::Classifier::getNumberOfNodes() const</a></td>
<td class="coverFnHi">282</td>
<td class="coverFnHi">94</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L170">bayesnet::Classifier::getNumberOfStates() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L94">bayesnet::Classifier::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">2550</td>
<td class="coverFnHi">850</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L101">bayesnet::Classifier::predict(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L115">bayesnet::Classifier::predict_proba(at::Tensor&amp;)</a></td>
<td class="coverFnHi">2226</td>
<td class="coverFnHi">742</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L122">bayesnet::Classifier::predict_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">390</td>
<td class="coverFnHi">130</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L137">bayesnet::Classifier::score(at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">168</td>
<td class="coverFnHi">56</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L142">bayesnet::Classifier::score(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L186">bayesnet::Classifier::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">126</td>
<td class="coverFnHi">42</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L149">bayesnet::Classifier::show[abi:cxx11]() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L178">bayesnet::Classifier::topological_order[abi:cxx11]()</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.cc.gcov.html#L42">bayesnet::Classifier::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1680</td>
<td class="coverFnHi">560</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -71,188 +71,188 @@
<span id="L9"><span class="lineNum"> 9</span> : #include &quot;Classifier.h&quot;</span>
<span id="L10"><span class="lineNum"> 10</span> : </span>
<span id="L11"><span class="lineNum"> 11</span> : namespace bayesnet {</span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC tlaBgGNC"> 2658 : Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC tlaBgGNC"> 886 : Classifier::Classifier(Network model) : model(model), m(0), n(0), metrics(Metrics()), fitted(false) {}</span></span>
<span id="L13"><span class="lineNum"> 13</span> : const std::string CLASSIFIER_NOT_FITTED = &quot;Classifier has not been fitted&quot;;</span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 1932 : Classifier&amp; Classifier::build(const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; weights)</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 644 : Classifier&amp; Classifier::build(const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; weights)</span></span>
<span id="L15"><span class="lineNum"> 15</span> : {</span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 1932 : this-&gt;features = features;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 1932 : this-&gt;className = className;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 1932 : this-&gt;states = states;</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 1932 : m = dataset.size(1);</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 1932 : n = features.size();</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 1932 : checkFitParameters();</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 1884 : auto n_classes = states.at(className).size();</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 1884 : metrics = Metrics(dataset, features, className, n_classes);</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 1884 : model.initialize();</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 1884 : buildModel(weights);</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 1884 : trainModel(weights);</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 1860 : fitted = true;</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 1860 : return *this;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 644 : this-&gt;features = features;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 644 : this-&gt;className = className;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 644 : this-&gt;states = states;</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 644 : m = dataset.size(1);</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 644 : n = features.size();</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 644 : checkFitParameters();</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 628 : auto n_classes = states.at(className).size();</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 628 : metrics = Metrics(dataset, features, className, n_classes);</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 628 : model.initialize();</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 628 : buildModel(weights);</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 628 : trainModel(weights);</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 620 : fitted = true;</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 620 : return *this;</span></span>
<span id="L29"><span class="lineNum"> 29</span> : }</span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 486 : void Classifier::buildDataset(torch::Tensor&amp; ytmp)</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 162 : void Classifier::buildDataset(torch::Tensor&amp; ytmp)</span></span>
<span id="L31"><span class="lineNum"> 31</span> : {</span>
<span id="L32"><span class="lineNum"> 32</span> : try {</span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 486 : auto yresized = torch::transpose(ytmp.view({ ytmp.size(0), 1 }), 0, 1);</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 1506 : dataset = torch::cat({ dataset, yresized }, 0);</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 486 : }</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 24 : catch (const std::exception&amp; e) {</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 24 : std::stringstream oss;</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 24 : oss &lt;&lt; &quot;* Error in X and y dimensions *\n&quot;;</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 24 : oss &lt;&lt; &quot;X dimensions: &quot; &lt;&lt; dataset.sizes() &lt;&lt; &quot;\n&quot;;</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 24 : oss &lt;&lt; &quot;y dimensions: &quot; &lt;&lt; ytmp.sizes();</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 24 : throw std::runtime_error(oss.str());</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 48 : }</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 972 : }</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 1680 : void Classifier::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 162 : auto yresized = torch::transpose(ytmp.view({ ytmp.size(0), 1 }), 0, 1);</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 502 : dataset = torch::cat({ dataset, yresized }, 0);</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 162 : }</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 8 : catch (const std::exception&amp; e) {</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 8 : std::stringstream oss;</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 8 : oss &lt;&lt; &quot;* Error in X and y dimensions *\n&quot;;</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 8 : oss &lt;&lt; &quot;X dimensions: &quot; &lt;&lt; dataset.sizes() &lt;&lt; &quot;\n&quot;;</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 8 : oss &lt;&lt; &quot;y dimensions: &quot; &lt;&lt; ytmp.sizes();</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 8 : throw std::runtime_error(oss.str());</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 16 : }</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 324 : }</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 560 : void Classifier::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L45"><span class="lineNum"> 45</span> : {</span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 1680 : model.fit(dataset, weights, features, className, states);</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 1680 : }</span></span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 560 : model.fit(dataset, weights, features, className, states);</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 560 : }</span></span>
<span id="L48"><span class="lineNum"> 48</span> : // X is nxm where n is the number of features and m the number of samples</span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 192 : Classifier&amp; Classifier::fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states)</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 64 : Classifier&amp; Classifier::fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states)</span></span>
<span id="L50"><span class="lineNum"> 50</span> : {</span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 192 : dataset = X;</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 192 : buildDataset(y);</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 180 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 312 : return build(features, className, states, weights);</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 180 : }</span></span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 64 : dataset = X;</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 64 : buildDataset(y);</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 60 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 104 : return build(features, className, states, weights);</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 60 : }</span></span>
<span id="L56"><span class="lineNum"> 56</span> : // X is nxm where n is the number of features and m the number of samples</span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 180 : Classifier&amp; Classifier::fit(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states)</span></span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 60 : Classifier&amp; Classifier::fit(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states)</span></span>
<span id="L58"><span class="lineNum"> 58</span> : {</span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 180 : dataset = torch::zeros({ static_cast&lt;int&gt;(X.size()), static_cast&lt;int&gt;(X[0].size()) }, torch::kInt32);</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 1254 : for (int i = 0; i &lt; X.size(); ++i) {</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 4296 : dataset.index_put_({ i, &quot;...&quot; }, torch::tensor(X[i], torch::kInt32));</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 60 : dataset = torch::zeros({ static_cast&lt;int&gt;(X.size()), static_cast&lt;int&gt;(X[0].size()) }, torch::kInt32);</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 418 : for (int i = 0; i &lt; X.size(); ++i) {</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 1432 : dataset.index_put_({ i, &quot;...&quot; }, torch::tensor(X[i], torch::kInt32));</span></span>
<span id="L62"><span class="lineNum"> 62</span> : }</span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 180 : auto ytmp = torch::tensor(y, torch::kInt32);</span></span>
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 180 : buildDataset(ytmp);</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 168 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 312 : return build(features, className, states, weights);</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 1278 : }</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 594 : Classifier&amp; Classifier::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states)</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 60 : auto ytmp = torch::tensor(y, torch::kInt32);</span></span>
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 60 : buildDataset(ytmp);</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 56 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 104 : return build(features, className, states, weights);</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 426 : }</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 198 : Classifier&amp; Classifier::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states)</span></span>
<span id="L69"><span class="lineNum"> 69</span> : {</span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 594 : this-&gt;dataset = dataset;</span></span>
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 594 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 1188 : return build(features, className, states, weights);</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 594 : }</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 990 : Classifier&amp; Classifier::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; weights)</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 198 : this-&gt;dataset = dataset;</span></span>
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 198 : const torch::Tensor weights = torch::full({ dataset.size(1) }, 1.0 / dataset.size(1), torch::kDouble);</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 396 : return build(features, className, states, weights);</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 198 : }</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 330 : Classifier&amp; Classifier::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states, const torch::Tensor&amp; weights)</span></span>
<span id="L75"><span class="lineNum"> 75</span> : {</span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 990 : this-&gt;dataset = dataset;</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 990 : return build(features, className, states, weights);</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 330 : this-&gt;dataset = dataset;</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 330 : return build(features, className, states, weights);</span></span>
<span id="L78"><span class="lineNum"> 78</span> : }</span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 1932 : void Classifier::checkFitParameters()</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 644 : void Classifier::checkFitParameters()</span></span>
<span id="L80"><span class="lineNum"> 80</span> : {</span>
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 1932 : if (torch::is_floating_point(dataset)) {</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 12 : throw std::invalid_argument(&quot;dataset (X, y) must be of type Integer&quot;);</span></span>
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 644 : if (torch::is_floating_point(dataset)) {</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;dataset (X, y) must be of type Integer&quot;);</span></span>
<span id="L83"><span class="lineNum"> 83</span> : }</span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 1920 : if (dataset.size(0) - 1 != features.size()) {</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 12 : throw std::invalid_argument(&quot;Classifier: X &quot; + std::to_string(dataset.size(0) - 1) + &quot; and features &quot; + std::to_string(features.size()) + &quot; must have the same number of features&quot;);</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 640 : if (dataset.size(0) - 1 != features.size()) {</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;Classifier: X &quot; + std::to_string(dataset.size(0) - 1) + &quot; and features &quot; + std::to_string(features.size()) + &quot; must have the same number of features&quot;);</span></span>
<span id="L86"><span class="lineNum"> 86</span> : }</span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 1908 : if (states.find(className) == states.end()) {</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 12 : throw std::invalid_argument(&quot;class name not found in states&quot;);</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 636 : if (states.find(className) == states.end()) {</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;class name not found in states&quot;);</span></span>
<span id="L89"><span class="lineNum"> 89</span> : }</span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 42624 : for (auto feature : features) {</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 40740 : if (states.find(feature) == states.end()) {</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 12 : throw std::invalid_argument(&quot;feature [&quot; + feature + &quot;] not found in states&quot;);</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 14208 : for (auto feature : features) {</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 13580 : if (states.find(feature) == states.end()) {</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;feature [&quot; + feature + &quot;] not found in states&quot;);</span></span>
<span id="L93"><span class="lineNum"> 93</span> : }</span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 40740 : }</span></span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 1884 : }</span></span>
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 2550 : torch::Tensor Classifier::predict(torch::Tensor&amp; X)</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 13580 : }</span></span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 628 : }</span></span>
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 850 : torch::Tensor Classifier::predict(torch::Tensor&amp; X)</span></span>
<span id="L97"><span class="lineNum"> 97</span> : {</span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 2550 : if (!fitted) {</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 24 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 850 : if (!fitted) {</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 8 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L100"><span class="lineNum"> 100</span> : }</span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 2526 : return model.predict(X);</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 842 : return model.predict(X);</span></span>
<span id="L102"><span class="lineNum"> 102</span> : }</span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 24 : std::vector&lt;int&gt; Classifier::predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 8 : std::vector&lt;int&gt; Classifier::predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L104"><span class="lineNum"> 104</span> : {</span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 24 : if (!fitted) {</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 12 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 8 : if (!fitted) {</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 4 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L107"><span class="lineNum"> 107</span> : }</span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 12 : auto m_ = X[0].size();</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 12 : auto n_ = X.size();</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 12 : std::vector&lt;std::vector&lt;int&gt;&gt; Xd(n_, std::vector&lt;int&gt;(m_, 0));</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 60 : for (auto i = 0; i &lt; n_; i++) {</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 96 : Xd[i] = std::vector&lt;int&gt;(X[i].begin(), X[i].end());</span></span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 4 : auto m_ = X[0].size();</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 4 : auto n_ = X.size();</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 4 : std::vector&lt;std::vector&lt;int&gt;&gt; Xd(n_, std::vector&lt;int&gt;(m_, 0));</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 20 : for (auto i = 0; i &lt; n_; i++) {</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 32 : Xd[i] = std::vector&lt;int&gt;(X[i].begin(), X[i].end());</span></span>
<span id="L113"><span class="lineNum"> 113</span> : }</span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 12 : auto yp = model.predict(Xd);</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 24 : return yp;</span></span>
<span id="L116"><span class="lineNum"> 116</span> <span class="tlaGNC"> 12 : }</span></span>
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 2226 : torch::Tensor Classifier::predict_proba(torch::Tensor&amp; X)</span></span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 4 : auto yp = model.predict(Xd);</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 8 : return yp;</span></span>
<span id="L116"><span class="lineNum"> 116</span> <span class="tlaGNC"> 4 : }</span></span>
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 742 : torch::Tensor Classifier::predict_proba(torch::Tensor&amp; X)</span></span>
<span id="L118"><span class="lineNum"> 118</span> : {</span>
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 2226 : if (!fitted) {</span></span>
<span id="L120"><span class="lineNum"> 120</span> <span class="tlaGNC"> 12 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 742 : if (!fitted) {</span></span>
<span id="L120"><span class="lineNum"> 120</span> <span class="tlaGNC"> 4 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L121"><span class="lineNum"> 121</span> : }</span>
<span id="L122"><span class="lineNum"> 122</span> <span class="tlaGNC"> 2214 : return model.predict_proba(X);</span></span>
<span id="L122"><span class="lineNum"> 122</span> <span class="tlaGNC"> 738 : return model.predict_proba(X);</span></span>
<span id="L123"><span class="lineNum"> 123</span> : }</span>
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 390 : std::vector&lt;std::vector&lt;double&gt;&gt; Classifier::predict_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 130 : std::vector&lt;std::vector&lt;double&gt;&gt; Classifier::predict_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L125"><span class="lineNum"> 125</span> : {</span>
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 390 : if (!fitted) {</span></span>
<span id="L127"><span class="lineNum"> 127</span> <span class="tlaGNC"> 12 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 130 : if (!fitted) {</span></span>
<span id="L127"><span class="lineNum"> 127</span> <span class="tlaGNC"> 4 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L128"><span class="lineNum"> 128</span> : }</span>
<span id="L129"><span class="lineNum"> 129</span> <span class="tlaGNC"> 378 : auto m_ = X[0].size();</span></span>
<span id="L130"><span class="lineNum"> 130</span> <span class="tlaGNC"> 378 : auto n_ = X.size();</span></span>
<span id="L131"><span class="lineNum"> 131</span> <span class="tlaGNC"> 378 : std::vector&lt;std::vector&lt;int&gt;&gt; Xd(n_, std::vector&lt;int&gt;(m_, 0));</span></span>
<span id="L129"><span class="lineNum"> 129</span> <span class="tlaGNC"> 126 : auto m_ = X[0].size();</span></span>
<span id="L130"><span class="lineNum"> 130</span> <span class="tlaGNC"> 126 : auto n_ = X.size();</span></span>
<span id="L131"><span class="lineNum"> 131</span> <span class="tlaGNC"> 126 : std::vector&lt;std::vector&lt;int&gt;&gt; Xd(n_, std::vector&lt;int&gt;(m_, 0));</span></span>
<span id="L132"><span class="lineNum"> 132</span> : // Convert to nxm vector</span>
<span id="L133"><span class="lineNum"> 133</span> <span class="tlaGNC"> 3240 : for (auto i = 0; i &lt; n_; i++) {</span></span>
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 5724 : Xd[i] = std::vector&lt;int&gt;(X[i].begin(), X[i].end());</span></span>
<span id="L133"><span class="lineNum"> 133</span> <span class="tlaGNC"> 1080 : for (auto i = 0; i &lt; n_; i++) {</span></span>
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 1908 : Xd[i] = std::vector&lt;int&gt;(X[i].begin(), X[i].end());</span></span>
<span id="L135"><span class="lineNum"> 135</span> : }</span>
<span id="L136"><span class="lineNum"> 136</span> <span class="tlaGNC"> 378 : auto yp = model.predict_proba(Xd);</span></span>
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 756 : return yp;</span></span>
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 378 : }</span></span>
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 168 : float Classifier::score(torch::Tensor&amp; X, torch::Tensor&amp; y)</span></span>
<span id="L136"><span class="lineNum"> 136</span> <span class="tlaGNC"> 126 : auto yp = model.predict_proba(Xd);</span></span>
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 252 : return yp;</span></span>
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 126 : }</span></span>
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 56 : float Classifier::score(torch::Tensor&amp; X, torch::Tensor&amp; y)</span></span>
<span id="L140"><span class="lineNum"> 140</span> : {</span>
<span id="L141"><span class="lineNum"> 141</span> <span class="tlaGNC"> 168 : torch::Tensor y_pred = predict(X);</span></span>
<span id="L142"><span class="lineNum"> 142</span> <span class="tlaGNC"> 312 : return (y_pred == y).sum().item&lt;float&gt;() / y.size(0);</span></span>
<span id="L143"><span class="lineNum"> 143</span> <span class="tlaGNC"> 156 : }</span></span>
<span id="L144"><span class="lineNum"> 144</span> <span class="tlaGNC"> 24 : float Classifier::score(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y)</span></span>
<span id="L141"><span class="lineNum"> 141</span> <span class="tlaGNC"> 56 : torch::Tensor y_pred = predict(X);</span></span>
<span id="L142"><span class="lineNum"> 142</span> <span class="tlaGNC"> 104 : return (y_pred == y).sum().item&lt;float&gt;() / y.size(0);</span></span>
<span id="L143"><span class="lineNum"> 143</span> <span class="tlaGNC"> 52 : }</span></span>
<span id="L144"><span class="lineNum"> 144</span> <span class="tlaGNC"> 8 : float Classifier::score(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y)</span></span>
<span id="L145"><span class="lineNum"> 145</span> : {</span>
<span id="L146"><span class="lineNum"> 146</span> <span class="tlaGNC"> 24 : if (!fitted) {</span></span>
<span id="L147"><span class="lineNum"> 147</span> <span class="tlaGNC"> 12 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L146"><span class="lineNum"> 146</span> <span class="tlaGNC"> 8 : if (!fitted) {</span></span>
<span id="L147"><span class="lineNum"> 147</span> <span class="tlaGNC"> 4 : throw std::logic_error(CLASSIFIER_NOT_FITTED);</span></span>
<span id="L148"><span class="lineNum"> 148</span> : }</span>
<span id="L149"><span class="lineNum"> 149</span> <span class="tlaGNC"> 12 : return model.score(X, y);</span></span>
<span id="L149"><span class="lineNum"> 149</span> <span class="tlaGNC"> 4 : return model.score(X, y);</span></span>
<span id="L150"><span class="lineNum"> 150</span> : }</span>
<span id="L151"><span class="lineNum"> 151</span> <span class="tlaGNC"> 36 : std::vector&lt;std::string&gt; Classifier::show() const</span></span>
<span id="L151"><span class="lineNum"> 151</span> <span class="tlaGNC"> 12 : std::vector&lt;std::string&gt; Classifier::show() const</span></span>
<span id="L152"><span class="lineNum"> 152</span> : {</span>
<span id="L153"><span class="lineNum"> 153</span> <span class="tlaGNC"> 36 : return model.show();</span></span>
<span id="L153"><span class="lineNum"> 153</span> <span class="tlaGNC"> 12 : return model.show();</span></span>
<span id="L154"><span class="lineNum"> 154</span> : }</span>
<span id="L155"><span class="lineNum"> 155</span> <span class="tlaGNC"> 1680 : void Classifier::addNodes()</span></span>
<span id="L155"><span class="lineNum"> 155</span> <span class="tlaGNC"> 560 : void Classifier::addNodes()</span></span>
<span id="L156"><span class="lineNum"> 156</span> : {</span>
<span id="L157"><span class="lineNum"> 157</span> : // Add all nodes to the network</span>
<span id="L158"><span class="lineNum"> 158</span> <span class="tlaGNC"> 39648 : for (const auto&amp; feature : features) {</span></span>
<span id="L159"><span class="lineNum"> 159</span> <span class="tlaGNC"> 37968 : model.addNode(feature);</span></span>
<span id="L158"><span class="lineNum"> 158</span> <span class="tlaGNC"> 13216 : for (const auto&amp; feature : features) {</span></span>
<span id="L159"><span class="lineNum"> 159</span> <span class="tlaGNC"> 12656 : model.addNode(feature);</span></span>
<span id="L160"><span class="lineNum"> 160</span> : }</span>
<span id="L161"><span class="lineNum"> 161</span> <span class="tlaGNC"> 1680 : model.addNode(className);</span></span>
<span id="L162"><span class="lineNum"> 162</span> <span class="tlaGNC"> 1680 : }</span></span>
<span id="L163"><span class="lineNum"> 163</span> <span class="tlaGNC"> 282 : int Classifier::getNumberOfNodes() const</span></span>
<span id="L161"><span class="lineNum"> 161</span> <span class="tlaGNC"> 560 : model.addNode(className);</span></span>
<span id="L162"><span class="lineNum"> 162</span> <span class="tlaGNC"> 560 : }</span></span>
<span id="L163"><span class="lineNum"> 163</span> <span class="tlaGNC"> 94 : int Classifier::getNumberOfNodes() const</span></span>
<span id="L164"><span class="lineNum"> 164</span> : {</span>
<span id="L165"><span class="lineNum"> 165</span> : // Features does not include class</span>
<span id="L166"><span class="lineNum"> 166</span> <span class="tlaGNC"> 282 : return fitted ? model.getFeatures().size() : 0;</span></span>
<span id="L166"><span class="lineNum"> 166</span> <span class="tlaGNC"> 94 : return fitted ? model.getFeatures().size() : 0;</span></span>
<span id="L167"><span class="lineNum"> 167</span> : }</span>
<span id="L168"><span class="lineNum"> 168</span> <span class="tlaGNC"> 282 : int Classifier::getNumberOfEdges() const</span></span>
<span id="L168"><span class="lineNum"> 168</span> <span class="tlaGNC"> 94 : int Classifier::getNumberOfEdges() const</span></span>
<span id="L169"><span class="lineNum"> 169</span> : {</span>
<span id="L170"><span class="lineNum"> 170</span> <span class="tlaGNC"> 282 : return fitted ? model.getNumEdges() : 0;</span></span>
<span id="L170"><span class="lineNum"> 170</span> <span class="tlaGNC"> 94 : return fitted ? model.getNumEdges() : 0;</span></span>
<span id="L171"><span class="lineNum"> 171</span> : }</span>
<span id="L172"><span class="lineNum"> 172</span> <span class="tlaGNC"> 36 : int Classifier::getNumberOfStates() const</span></span>
<span id="L172"><span class="lineNum"> 172</span> <span class="tlaGNC"> 12 : int Classifier::getNumberOfStates() const</span></span>
<span id="L173"><span class="lineNum"> 173</span> : {</span>
<span id="L174"><span class="lineNum"> 174</span> <span class="tlaGNC"> 36 : return fitted ? model.getStates() : 0;</span></span>
<span id="L174"><span class="lineNum"> 174</span> <span class="tlaGNC"> 12 : return fitted ? model.getStates() : 0;</span></span>
<span id="L175"><span class="lineNum"> 175</span> : }</span>
<span id="L176"><span class="lineNum"> 176</span> <span class="tlaGNC"> 510 : int Classifier::getClassNumStates() const</span></span>
<span id="L176"><span class="lineNum"> 176</span> <span class="tlaGNC"> 170 : int Classifier::getClassNumStates() const</span></span>
<span id="L177"><span class="lineNum"> 177</span> : {</span>
<span id="L178"><span class="lineNum"> 178</span> <span class="tlaGNC"> 510 : return fitted ? model.getClassNumStates() : 0;</span></span>
<span id="L178"><span class="lineNum"> 178</span> <span class="tlaGNC"> 170 : return fitted ? model.getClassNumStates() : 0;</span></span>
<span id="L179"><span class="lineNum"> 179</span> : }</span>
<span id="L180"><span class="lineNum"> 180</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; Classifier::topological_order()</span></span>
<span id="L180"><span class="lineNum"> 180</span> <span class="tlaGNC"> 2 : std::vector&lt;std::string&gt; Classifier::topological_order()</span></span>
<span id="L181"><span class="lineNum"> 181</span> : {</span>
<span id="L182"><span class="lineNum"> 182</span> <span class="tlaGNC"> 6 : return model.topological_sort();</span></span>
<span id="L182"><span class="lineNum"> 182</span> <span class="tlaGNC"> 2 : return model.topological_sort();</span></span>
<span id="L183"><span class="lineNum"> 183</span> : }</span>
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 6 : std::string Classifier::dump_cpt() const</span></span>
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 2 : std::string Classifier::dump_cpt() const</span></span>
<span id="L185"><span class="lineNum"> 185</span> : {</span>
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 6 : return model.dump_cpt();</span></span>
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 2 : return model.dump_cpt();</span></span>
<span id="L187"><span class="lineNum"> 187</span> : }</span>
<span id="L188"><span class="lineNum"> 188</span> <span class="tlaGNC"> 126 : void Classifier::setHyperparameters(const nlohmann::json&amp; hyperparameters)</span></span>
<span id="L188"><span class="lineNum"> 188</span> <span class="tlaGNC"> 42 : void Classifier::setHyperparameters(const nlohmann::json&amp; hyperparameters)</span></span>
<span id="L189"><span class="lineNum"> 189</span> : {</span>
<span id="L190"><span class="lineNum"> 190</span> <span class="tlaGNC"> 126 : if (!hyperparameters.empty()) {</span></span>
<span id="L191"><span class="lineNum"> 191</span> <span class="tlaGNC"> 12 : throw std::invalid_argument(&quot;Invalid hyperparameters&quot; + hyperparameters.dump());</span></span>
<span id="L190"><span class="lineNum"> 190</span> <span class="tlaGNC"> 42 : if (!hyperparameters.empty()) {</span></span>
<span id="L191"><span class="lineNum"> 191</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;Invalid hyperparameters&quot; + hyperparameters.dump());</span></span>
<span id="L192"><span class="lineNum"> 192</span> : }</span>
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 114 : }</span></span>
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 38 : }</span></span>
<span id="L194"><span class="lineNum"> 194</span> : }</span>
</pre>
</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L31">bayesnet::Classifier::getVersion[abi:cxx11]()</a></td>
<td class="coverFnHi">48</td>
<td class="coverFnHi">16</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">bayesnet::Classifier::getNotes[abi:cxx11]() const</a></td>
<td class="coverFnHi">114</td>
<td class="coverFnHi">38</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">bayesnet::Classifier::getStatus() const</a></td>
<td class="coverFnHi">192</td>
<td class="coverFnHi">64</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">bayesnet::Classifier::~Classifier()</a></td>
<td class="coverFnHi">1818</td>
<td class="coverFnHi">606</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L36">bayesnet::Classifier::getNotes[abi:cxx11]() const</a></td>
<td class="coverFnHi">114</td>
<td class="coverFnHi">38</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L30">bayesnet::Classifier::getStatus() const</a></td>
<td class="coverFnHi">192</td>
<td class="coverFnHi">64</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L31">bayesnet::Classifier::getVersion[abi:cxx11]()</a></td>
<td class="coverFnHi">48</td>
<td class="coverFnHi">16</td>
</tr>
<tr>
<td class="coverFn"><a href="Classifier.h.gcov.html#L16">bayesnet::Classifier::~Classifier()</a></td>
<td class="coverFnHi">1818</td>
<td class="coverFnHi">606</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -77,7 +77,7 @@
<span id="L15"><span class="lineNum"> 15</span> : class Classifier : public BaseClassifier {</span>
<span id="L16"><span class="lineNum"> 16</span> : public:</span>
<span id="L17"><span class="lineNum"> 17</span> : Classifier(Network model);</span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC tlaBgGNC"> 1818 : virtual ~Classifier() = default;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC tlaBgGNC"> 606 : virtual ~Classifier() = default;</span></span>
<span id="L19"><span class="lineNum"> 19</span> : Classifier&amp; fit(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L20"><span class="lineNum"> 20</span> : Classifier&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L21"><span class="lineNum"> 21</span> : Classifier&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, std::map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
@ -91,13 +91,13 @@
<span id="L29"><span class="lineNum"> 29</span> : std::vector&lt;int&gt; predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X) override;</span>
<span id="L30"><span class="lineNum"> 30</span> : torch::Tensor predict_proba(torch::Tensor&amp; X) override;</span>
<span id="L31"><span class="lineNum"> 31</span> : std::vector&lt;std::vector&lt;double&gt;&gt; predict_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X) override;</span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 192 : status_t getStatus() const override { return status; }</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 144 : std::string getVersion() override { return { project_version.begin(), project_version.end() }; };</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 64 : status_t getStatus() const override { return status; }</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 48 : std::string getVersion() override { return { project_version.begin(), project_version.end() }; };</span></span>
<span id="L34"><span class="lineNum"> 34</span> : float score(torch::Tensor&amp; X, torch::Tensor&amp; y) override;</span>
<span id="L35"><span class="lineNum"> 35</span> : float score(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y) override;</span>
<span id="L36"><span class="lineNum"> 36</span> : std::vector&lt;std::string&gt; show() const override;</span>
<span id="L37"><span class="lineNum"> 37</span> : std::vector&lt;std::string&gt; topological_order() override;</span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 114 : std::vector&lt;std::string&gt; getNotes() const override { return notes; }</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 38 : std::vector&lt;std::string&gt; getNotes() const override { return notes; }</span></span>
<span id="L39"><span class="lineNum"> 39</span> : std::string dump_cpt() const override;</span>
<span id="L40"><span class="lineNum"> 40</span> : void setHyperparameters(const nlohmann::json&amp; hyperparameters) override; //For classifiers that don't have hyperparameters</span>
<span id="L41"><span class="lineNum"> 41</span> : protected:</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,35 +65,35 @@
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L101">bayesnet::KDB::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">bayesnet::KDB::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">18</td>
<td class="coverFnHi">6</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L26">bayesnet::KDB::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">78</td>
<td class="coverFnHi">26</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">bayesnet::KDB::KDB(int, float)</a></td>
<td class="coverFnHi">222</td>
<td class="coverFnHi">74</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">bayesnet::KDB::add_m_edges(int, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">516</td>
<td class="coverFnHi">172</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,35 +65,35 @@
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L8">bayesnet::KDB::KDB(int, float)</a></td>
<td class="coverFnHi">222</td>
<td class="coverFnHi">74</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L77">bayesnet::KDB::add_m_edges(int, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">516</td>
<td class="coverFnHi">172</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L26">bayesnet::KDB::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">78</td>
<td class="coverFnHi">26</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L101">bayesnet::KDB::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="KDB.cc.gcov.html#L13">bayesnet::KDB::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">18</td>
<td class="coverFnHi">6</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -69,25 +69,25 @@
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;KDB.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 222 : KDB::KDB(int k, float theta) : Classifier(Network()), k(k), theta(theta)</span></span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 74 : KDB::KDB(int k, float theta) : Classifier(Network()), k(k), theta(theta)</span></span>
<span id="L11"><span class="lineNum"> 11</span> : {</span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 666 : validHyperparameters = { &quot;k&quot;, &quot;theta&quot; };</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 222 : validHyperparameters = { &quot;k&quot;, &quot;theta&quot; };</span></span>
<span id="L13"><span class="lineNum"> 13</span> : </span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 666 : }</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 18 : void KDB::setHyperparameters(const nlohmann::json&amp; hyperparameters_)</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 222 : }</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 6 : void KDB::setHyperparameters(const nlohmann::json&amp; hyperparameters_)</span></span>
<span id="L16"><span class="lineNum"> 16</span> : {</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 18 : auto hyperparameters = hyperparameters_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 18 : if (hyperparameters.contains(&quot;k&quot;)) {</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 6 : k = hyperparameters[&quot;k&quot;];</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 6 : hyperparameters.erase(&quot;k&quot;);</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 6 : auto hyperparameters = hyperparameters_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 6 : if (hyperparameters.contains(&quot;k&quot;)) {</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 2 : k = hyperparameters[&quot;k&quot;];</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 2 : hyperparameters.erase(&quot;k&quot;);</span></span>
<span id="L21"><span class="lineNum"> 21</span> : }</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 18 : if (hyperparameters.contains(&quot;theta&quot;)) {</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 6 : theta = hyperparameters[&quot;theta&quot;];</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 6 : hyperparameters.erase(&quot;theta&quot;);</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 6 : if (hyperparameters.contains(&quot;theta&quot;)) {</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 2 : theta = hyperparameters[&quot;theta&quot;];</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 2 : hyperparameters.erase(&quot;theta&quot;);</span></span>
<span id="L25"><span class="lineNum"> 25</span> : }</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 18 : Classifier::setHyperparameters(hyperparameters);</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 18 : }</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 78 : void KDB::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 6 : Classifier::setHyperparameters(hyperparameters);</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 6 : }</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 26 : void KDB::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L29"><span class="lineNum"> 29</span> : {</span>
<span id="L30"><span class="lineNum"> 30</span> : /*</span>
<span id="L31"><span class="lineNum"> 31</span> : 1. For each feature Xi, compute mutual information, I(X;C),</span>
@ -110,66 +110,66 @@
<span id="L48"><span class="lineNum"> 48</span> : */</span>
<span id="L49"><span class="lineNum"> 49</span> : // 1. For each feature Xi, compute mutual information, I(X;C),</span>
<span id="L50"><span class="lineNum"> 50</span> : // where C is the class.</span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 78 : addNodes();</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 234 : const torch::Tensor&amp; y = dataset.index({ -1, &quot;...&quot; });</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 78 : std::vector&lt;double&gt; mi;</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 594 : for (auto i = 0; i &lt; features.size(); i++) {</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 1548 : torch::Tensor firstFeature = dataset.index({ i, &quot;...&quot; });</span></span>
<span id="L56"><span class="lineNum"> 56</span> <span class="tlaGNC"> 516 : mi.push_back(metrics.mutualInformation(firstFeature, y, weights));</span></span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 516 : }</span></span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 26 : addNodes();</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 78 : const torch::Tensor&amp; y = dataset.index({ -1, &quot;...&quot; });</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 26 : std::vector&lt;double&gt; mi;</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 198 : for (auto i = 0; i &lt; features.size(); i++) {</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 516 : torch::Tensor firstFeature = dataset.index({ i, &quot;...&quot; });</span></span>
<span id="L56"><span class="lineNum"> 56</span> <span class="tlaGNC"> 172 : mi.push_back(metrics.mutualInformation(firstFeature, y, weights));</span></span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 172 : }</span></span>
<span id="L58"><span class="lineNum"> 58</span> : // 2. Compute class conditional mutual information I(Xi;XjIC), f or each</span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 78 : auto conditionalEdgeWeights = metrics.conditionalEdge(weights);</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 26 : auto conditionalEdgeWeights = metrics.conditionalEdge(weights);</span></span>
<span id="L60"><span class="lineNum"> 60</span> : // 3. Let the used variable list, S, be empty.</span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 78 : std::vector&lt;int&gt; S;</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 26 : std::vector&lt;int&gt; S;</span></span>
<span id="L62"><span class="lineNum"> 62</span> : // 4. Let the DAG network being constructed, BN, begin with a single</span>
<span id="L63"><span class="lineNum"> 63</span> : // class node, C.</span>
<span id="L64"><span class="lineNum"> 64</span> : // 5. Repeat until S includes all domain features</span>
<span id="L65"><span class="lineNum"> 65</span> : // 5.1. Select feature Xmax which is not in S and has the largest value</span>
<span id="L66"><span class="lineNum"> 66</span> : // I(Xmax;C).</span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 78 : auto order = argsort(mi);</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 594 : for (auto idx : order) {</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 26 : auto order = argsort(mi);</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 198 : for (auto idx : order) {</span></span>
<span id="L69"><span class="lineNum"> 69</span> : // 5.2. Add a node to BN representing Xmax.</span>
<span id="L70"><span class="lineNum"> 70</span> : // 5.3. Add an arc from C to Xmax in BN.</span>
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 516 : model.addEdge(className, features[idx]);</span></span>
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 172 : model.addEdge(className, features[idx]);</span></span>
<span id="L72"><span class="lineNum"> 72</span> : // 5.4. Add m = min(lSl,/c) arcs from m distinct features Xj in S with</span>
<span id="L73"><span class="lineNum"> 73</span> : // the highest value for I(Xmax;X,jC).</span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 516 : add_m_edges(idx, S, conditionalEdgeWeights);</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 172 : add_m_edges(idx, S, conditionalEdgeWeights);</span></span>
<span id="L75"><span class="lineNum"> 75</span> : // 5.5. Add Xmax to S.</span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 516 : S.push_back(idx);</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 172 : S.push_back(idx);</span></span>
<span id="L77"><span class="lineNum"> 77</span> : }</span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 672 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 516 : void KDB::add_m_edges(int idx, std::vector&lt;int&gt;&amp; S, torch::Tensor&amp; weights)</span></span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 224 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 172 : void KDB::add_m_edges(int idx, std::vector&lt;int&gt;&amp; S, torch::Tensor&amp; weights)</span></span>
<span id="L80"><span class="lineNum"> 80</span> : {</span>
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 516 : auto n_edges = std::min(k, static_cast&lt;int&gt;(S.size()));</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 516 : auto cond_w = clone(weights);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 516 : bool exit_cond = k == 0;</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 516 : int num = 0;</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 1506 : while (!exit_cond) {</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 3960 : auto max_minfo = argmax(cond_w.index({ idx, &quot;...&quot; })).item&lt;int&gt;();</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 990 : auto belongs = find(S.begin(), S.end(), max_minfo) != S.end();</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 2646 : if (belongs &amp;&amp; cond_w.index({ idx, max_minfo }).item&lt;float&gt;() &gt; theta) {</span></span>
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 172 : auto n_edges = std::min(k, static_cast&lt;int&gt;(S.size()));</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 172 : auto cond_w = clone(weights);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 172 : bool exit_cond = k == 0;</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 172 : int num = 0;</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 502 : while (!exit_cond) {</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 1320 : auto max_minfo = argmax(cond_w.index({ idx, &quot;...&quot; })).item&lt;int&gt;();</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 330 : auto belongs = find(S.begin(), S.end(), max_minfo) != S.end();</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 882 : if (belongs &amp;&amp; cond_w.index({ idx, max_minfo }).item&lt;float&gt;() &gt; theta) {</span></span>
<span id="L89"><span class="lineNum"> 89</span> : try {</span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 480 : model.addEdge(features[max_minfo], features[idx]);</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 480 : num++;</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 160 : model.addEdge(features[max_minfo], features[idx]);</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 160 : num++;</span></span>
<span id="L92"><span class="lineNum"> 92</span> : }</span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaUNC tlaBgUNC"> 0 : catch (const std::invalid_argument&amp; e) {</span></span>
<span id="L94"><span class="lineNum"> 94</span> : // Loops are not allowed</span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaUNC"> 0 : }</span></span>
<span id="L96"><span class="lineNum"> 96</span> : }</span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC tlaBgGNC"> 3960 : cond_w.index_put_({ idx, max_minfo }, -1);</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 2970 : auto candidates_mask = cond_w.index({ idx, &quot;...&quot; }).gt(theta);</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 990 : auto candidates = candidates_mask.nonzero();</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 990 : exit_cond = num == n_edges || candidates.size(0) == 0;</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 990 : }</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 4038 : }</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 12 : std::vector&lt;std::string&gt; KDB::graph(const std::string&amp; title) const</span></span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC tlaBgGNC"> 1320 : cond_w.index_put_({ idx, max_minfo }, -1);</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 990 : auto candidates_mask = cond_w.index({ idx, &quot;...&quot; }).gt(theta);</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 330 : auto candidates = candidates_mask.nonzero();</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 330 : exit_cond = num == n_edges || candidates.size(0) == 0;</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 330 : }</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 1346 : }</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 4 : std::vector&lt;std::string&gt; KDB::graph(const std::string&amp; title) const</span></span>
<span id="L104"><span class="lineNum"> 104</span> : {</span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 12 : std::string header{ title };</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 12 : if (title == &quot;KDB&quot;) {</span></span>
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 12 : header += &quot; (k=&quot; + std::to_string(k) + &quot;, theta=&quot; + std::to_string(theta) + &quot;)&quot;;</span></span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 4 : std::string header{ title };</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 4 : if (title == &quot;KDB&quot;) {</span></span>
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 4 : header += &quot; (k=&quot; + std::to_string(k) + &quot;, theta=&quot; + std::to_string(theta) + &quot;)&quot;;</span></span>
<span id="L108"><span class="lineNum"> 108</span> : }</span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 24 : return model.graph(header);</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 12 : }</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 8 : return model.graph(header);</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 4 : }</span></span>
<span id="L111"><span class="lineNum"> 111</span> : }</span>
</pre>
</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="KDB.h.gcov.html#L20">bayesnet::KDB::~KDB()</a></td>
<td class="coverFnHi">66</td>
<td class="coverFnHi">22</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="KDB.h.gcov.html#L20">bayesnet::KDB::~KDB()</a></td>
<td class="coverFnHi">66</td>
<td class="coverFnHi">22</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -81,7 +81,7 @@
<span id="L19"><span class="lineNum"> 19</span> : void buildModel(const torch::Tensor&amp; weights) override;</span>
<span id="L20"><span class="lineNum"> 20</span> : public:</span>
<span id="L21"><span class="lineNum"> 21</span> : explicit KDB(int k, float theta = 0.03);</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC tlaBgGNC"> 66 : virtual ~KDB() = default;</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC tlaBgGNC"> 22 : virtual ~KDB() = default;</span></span>
<span id="L23"><span class="lineNum"> 23</span> : void setHyperparameters(const nlohmann::json&amp; hyperparameters_) override;</span>
<span id="L24"><span class="lineNum"> 24</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;KDB&quot;) const override;</span>
<span id="L25"><span class="lineNum"> 25</span> : };</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L29">bayesnet::KDBLd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">bayesnet::KDBLd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L9">bayesnet::KDBLd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">bayesnet::KDBLd::KDBLd(int)</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L8">bayesnet::KDBLd::KDBLd(int)</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L9">bayesnet::KDBLd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L29">bayesnet::KDBLd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="KDBLd.cc.gcov.html#L24">bayesnet::KDBLd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -69,30 +69,30 @@
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;KDBLd.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 102 : KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 30 : KDBLd&amp; KDBLd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 34 : KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 10 : KDBLd&amp; KDBLd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L12"><span class="lineNum"> 12</span> : {</span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 30 : checkInput(X_, y_);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 30 : features = features_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 30 : className = className_;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 30 : Xf = X_;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 30 : y = y_;</span></span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 10 : checkInput(X_, y_);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 10 : features = features_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 10 : className = className_;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 10 : Xf = X_;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 10 : y = y_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : // Fills std::vectors Xv &amp; yv with the data from tensors X_ (discretized) &amp; y</span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 30 : states = fit_local_discretization(y);</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 10 : states = fit_local_discretization(y);</span></span>
<span id="L20"><span class="lineNum"> 20</span> : // We have discretized the input data</span>
<span id="L21"><span class="lineNum"> 21</span> : // 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 30 : KDB::fit(dataset, features, className, states);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 30 : states = localDiscretizationProposal(states, model);</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 30 : return *this;</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 10 : KDB::fit(dataset, features, className, states);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 10 : states = localDiscretizationProposal(states, model);</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 10 : return *this;</span></span>
<span id="L25"><span class="lineNum"> 25</span> : }</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 24 : torch::Tensor KDBLd::predict(torch::Tensor&amp; X)</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 8 : torch::Tensor KDBLd::predict(torch::Tensor&amp; X)</span></span>
<span id="L27"><span class="lineNum"> 27</span> : {</span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 24 : auto Xt = prepareX(X);</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 48 : return KDB::predict(Xt);</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 24 : }</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; KDBLd::graph(const std::string&amp; name) const</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 8 : auto Xt = prepareX(X);</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 16 : return KDB::predict(Xt);</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 8 : }</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 2 : std::vector&lt;std::string&gt; KDBLd::graph(const std::string&amp; name) const</span></span>
<span id="L32"><span class="lineNum"> 32</span> : {</span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 6 : return KDB::graph(name);</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 2 : return KDB::graph(name);</span></span>
<span id="L34"><span class="lineNum"> 34</span> : }</span>
<span id="L35"><span class="lineNum"> 35</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="KDBLd.h.gcov.html#L15">bayesnet::KDBLd::~KDBLd()</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="KDBLd.h.gcov.html#L15">bayesnet::KDBLd::~KDBLd()</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -76,7 +76,7 @@
<span id="L14"><span class="lineNum"> 14</span> : private:</span>
<span id="L15"><span class="lineNum"> 15</span> : public:</span>
<span id="L16"><span class="lineNum"> 16</span> : explicit KDBLd(int k);</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 30 : virtual ~KDBLd() = default;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 10 : virtual ~KDBLd() = default;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : KDBLd&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L19"><span class="lineNum"> 19</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;KDB&quot;) const override;</span>
<span id="L20"><span class="lineNum"> 20</span> : torch::Tensor predict(torch::Tensor&amp; X) override;</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,56 +65,56 @@
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L104">bayesnet::Proposal::prepareX(at::Tensor&amp;)</a></td>
<td class="coverFnHi">252</td>
<td class="coverFnHi">84</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">bayesnet::Proposal::~Proposal()</a></td>
<td class="coverFnHi">300</td>
<td class="coverFnHi">100</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)</a></td>
<td class="coverFnHi">318</td>
<td class="coverFnHi">106</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L16">bayesnet::Proposal::checkInput(at::Tensor const&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">342</td>
<td class="coverFnHi">114</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">bayesnet::Proposal::fit_local_discretization[abi:cxx11](at::Tensor const&amp;)</a></td>
<td class="coverFnHi">348</td>
<td class="coverFnHi">116</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">bayesnet::Proposal::Proposal(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">636</td>
<td class="coverFnHi">212</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#2}::operator()&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">2058</td>
<td class="coverFnHi">686</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#1}::operator()&lt;bayesnet::Node*&gt;(bayesnet::Node* const&amp;) const</a></td>
<td class="coverFnHi">4044</td>
<td class="coverFnHi">1348</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,56 +65,56 @@
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L41">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#1}::operator()&lt;bayesnet::Node*&gt;(bayesnet::Node* const&amp;) const</a></td>
<td class="coverFnHi">4044</td>
<td class="coverFnHi">1348</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L47">auto bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)::{lambda(auto:1 const&amp;)#2}::operator()&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">2058</td>
<td class="coverFnHi">686</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L9">bayesnet::Proposal::Proposal(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">636</td>
<td class="coverFnHi">212</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L16">bayesnet::Proposal::checkInput(at::Tensor const&amp;, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">342</td>
<td class="coverFnHi">114</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L77">bayesnet::Proposal::fit_local_discretization[abi:cxx11](at::Tensor const&amp;)</a></td>
<td class="coverFnHi">348</td>
<td class="coverFnHi">116</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L25">bayesnet::Proposal::localDiscretizationProposal(std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt; const&amp;, bayesnet::Network&amp;)</a></td>
<td class="coverFnHi">318</td>
<td class="coverFnHi">106</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L104">bayesnet::Proposal::prepareX(at::Tensor&amp;)</a></td>
<td class="coverFnHi">252</td>
<td class="coverFnHi">84</td>
</tr>
<tr>
<td class="coverFn"><a href="Proposal.cc.gcov.html#L10">bayesnet::Proposal::~Proposal()</a></td>
<td class="coverFnHi">300</td>
<td class="coverFnHi">100</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -70,111 +70,111 @@
<span id="L8"><span class="lineNum"> 8</span> : #include &quot;Proposal.h&quot;</span>
<span id="L9"><span class="lineNum"> 9</span> : </span>
<span id="L10"><span class="lineNum"> 10</span> : namespace bayesnet {</span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 636 : Proposal::Proposal(torch::Tensor&amp; dataset_, std::vector&lt;std::string&gt;&amp; features_, std::string&amp; className_) : pDataset(dataset_), pFeatures(features_), pClassName(className_) {}</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 300 : Proposal::~Proposal()</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 212 : Proposal::Proposal(torch::Tensor&amp; dataset_, std::vector&lt;std::string&gt;&amp; features_, std::string&amp; className_) : pDataset(dataset_), pFeatures(features_), pClassName(className_) {}</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 100 : Proposal::~Proposal()</span></span>
<span id="L13"><span class="lineNum"> 13</span> : {</span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 2844 : for (auto&amp; [key, value] : discretizers) {</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 2544 : delete value;</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 948 : for (auto&amp; [key, value] : discretizers) {</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 848 : delete value;</span></span>
<span id="L16"><span class="lineNum"> 16</span> : }</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 300 : }</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 342 : void Proposal::checkInput(const torch::Tensor&amp; X, const torch::Tensor&amp; y)</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 100 : }</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 114 : void Proposal::checkInput(const torch::Tensor&amp; X, const torch::Tensor&amp; y)</span></span>
<span id="L19"><span class="lineNum"> 19</span> : {</span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 342 : if (!torch::is_floating_point(X)) {</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 114 : if (!torch::is_floating_point(X)) {</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaUNC tlaBgUNC"> 0 : throw std::invalid_argument(&quot;X must be a floating point tensor&quot;);</span></span>
<span id="L22"><span class="lineNum"> 22</span> : }</span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC tlaBgGNC"> 342 : if (torch::is_floating_point(y)) {</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC tlaBgGNC"> 114 : if (torch::is_floating_point(y)) {</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaUNC tlaBgUNC"> 0 : throw std::invalid_argument(&quot;y must be an integer tensor&quot;);</span></span>
<span id="L25"><span class="lineNum"> 25</span> : }</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC tlaBgGNC"> 342 : }</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 318 : map&lt;std::string, std::vector&lt;int&gt;&gt; Proposal::localDiscretizationProposal(const map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; oldStates, Network&amp; model)</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC tlaBgGNC"> 114 : }</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 106 : map&lt;std::string, std::vector&lt;int&gt;&gt; Proposal::localDiscretizationProposal(const map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; oldStates, Network&amp; model)</span></span>
<span id="L28"><span class="lineNum"> 28</span> : {</span>
<span id="L29"><span class="lineNum"> 29</span> : // order of local discretization is important. no good 0, 1, 2...</span>
<span id="L30"><span class="lineNum"> 30</span> : // although we rediscretize features after the local discretization of every feature</span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 318 : auto order = model.topological_sort();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 318 : auto&amp; nodes = model.getNodes();</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 318 : map&lt;std::string, std::vector&lt;int&gt;&gt; states = oldStates;</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 318 : std::vector&lt;int&gt; indicesToReDiscretize;</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 318 : bool upgrade = false; // Flag to check if we need to upgrade the model</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 2664 : for (auto feature : order) {</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 2346 : auto nodeParents = nodes[feature]-&gt;getParents();</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 2346 : if (nodeParents.size() &lt; 2) continue; // Only has class as parent</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 1986 : upgrade = true;</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 1986 : int index = find(pFeatures.begin(), pFeatures.end(), feature) - pFeatures.begin();</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 1986 : indicesToReDiscretize.push_back(index); // We need to re-discretize this feature</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 1986 : std::vector&lt;std::string&gt; parents;</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 6030 : transform(nodeParents.begin(), nodeParents.end(), back_inserter(parents), [](const auto&amp; p) { return p-&gt;getName(); });</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 106 : auto order = model.topological_sort();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 106 : auto&amp; nodes = model.getNodes();</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 106 : map&lt;std::string, std::vector&lt;int&gt;&gt; states = oldStates;</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 106 : std::vector&lt;int&gt; indicesToReDiscretize;</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 106 : bool upgrade = false; // Flag to check if we need to upgrade the model</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 888 : for (auto feature : order) {</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 782 : auto nodeParents = nodes[feature]-&gt;getParents();</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 782 : if (nodeParents.size() &lt; 2) continue; // Only has class as parent</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 662 : upgrade = true;</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 662 : int index = find(pFeatures.begin(), pFeatures.end(), feature) - pFeatures.begin();</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 662 : indicesToReDiscretize.push_back(index); // We need to re-discretize this feature</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 662 : std::vector&lt;std::string&gt; parents;</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 2010 : transform(nodeParents.begin(), nodeParents.end(), back_inserter(parents), [](const auto&amp; p) { return p-&gt;getName(); });</span></span>
<span id="L44"><span class="lineNum"> 44</span> : // Remove class as parent as it will be added later</span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 1986 : parents.erase(remove(parents.begin(), parents.end(), pClassName), parents.end());</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 662 : parents.erase(remove(parents.begin(), parents.end(), pClassName), parents.end());</span></span>
<span id="L46"><span class="lineNum"> 46</span> : // Get the indices of the parents</span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 1986 : std::vector&lt;int&gt; indices;</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 1986 : indices.push_back(-1); // Add class index</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 4044 : transform(parents.begin(), parents.end(), back_inserter(indices), [&amp;](const auto&amp; p) {return find(pFeatures.begin(), pFeatures.end(), p) - pFeatures.begin(); });</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 662 : std::vector&lt;int&gt; indices;</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 662 : indices.push_back(-1); // Add class index</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 1348 : transform(parents.begin(), parents.end(), back_inserter(indices), [&amp;](const auto&amp; p) {return find(pFeatures.begin(), pFeatures.end(), p) - pFeatures.begin(); });</span></span>
<span id="L50"><span class="lineNum"> 50</span> : // Now we fit the discretizer of the feature, conditioned on its parents and the class i.e. discretizer.fit(X[index], X[indices] + y)</span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 1986 : std::vector&lt;std::string&gt; yJoinParents(Xf.size(1));</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 6030 : for (auto idx : indices) {</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 1437960 : for (int i = 0; i &lt; Xf.size(1); ++i) {</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 4301748 : yJoinParents[i] += to_string(pDataset.index({ idx, i }).item&lt;int&gt;());</span></span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 662 : std::vector&lt;std::string&gt; yJoinParents(Xf.size(1));</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 2010 : for (auto idx : indices) {</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 479320 : for (int i = 0; i &lt; Xf.size(1); ++i) {</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 1433916 : yJoinParents[i] += to_string(pDataset.index({ idx, i }).item&lt;int&gt;());</span></span>
<span id="L55"><span class="lineNum"> 55</span> : }</span>
<span id="L56"><span class="lineNum"> 56</span> : }</span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 1986 : auto arff = ArffFiles();</span></span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 1986 : auto yxv = arff.factorize(yJoinParents);</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 3972 : auto xvf_ptr = Xf.index({ index }).data_ptr&lt;float&gt;();</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 1986 : auto xvf = std::vector&lt;mdlp::precision_t&gt;(xvf_ptr, xvf_ptr + Xf.size(1));</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 1986 : discretizers[feature]-&gt;fit(xvf, yxv);</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 2706 : }</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 318 : if (upgrade) {</span></span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 662 : auto arff = ArffFiles();</span></span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 662 : auto yxv = arff.factorize(yJoinParents);</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 1324 : auto xvf_ptr = Xf.index({ index }).data_ptr&lt;float&gt;();</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 662 : auto xvf = std::vector&lt;mdlp::precision_t&gt;(xvf_ptr, xvf_ptr + Xf.size(1));</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 662 : discretizers[feature]-&gt;fit(xvf, yxv);</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 902 : }</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 106 : if (upgrade) {</span></span>
<span id="L64"><span class="lineNum"> 64</span> : // Discretize again X (only the affected indices) with the new fitted discretizers</span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 2304 : for (auto index : indicesToReDiscretize) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 3972 : auto Xt_ptr = Xf.index({ index }).data_ptr&lt;float&gt;();</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 1986 : auto Xt = std::vector&lt;float&gt;(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 7944 : pDataset.index_put_({ index, &quot;...&quot; }, torch::tensor(discretizers[pFeatures[index]]-&gt;transform(Xt)));</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 1986 : auto xStates = std::vector&lt;int&gt;(discretizers[pFeatures[index]]-&gt;getCutPoints().size() + 1);</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 1986 : iota(xStates.begin(), xStates.end(), 0);</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 768 : for (auto index : indicesToReDiscretize) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 1324 : auto Xt_ptr = Xf.index({ index }).data_ptr&lt;float&gt;();</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 662 : auto Xt = std::vector&lt;float&gt;(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 2648 : pDataset.index_put_({ index, &quot;...&quot; }, torch::tensor(discretizers[pFeatures[index]]-&gt;transform(Xt)));</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 662 : auto xStates = std::vector&lt;int&gt;(discretizers[pFeatures[index]]-&gt;getCutPoints().size() + 1);</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 662 : iota(xStates.begin(), xStates.end(), 0);</span></span>
<span id="L71"><span class="lineNum"> 71</span> : //Update new states of the feature/node</span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 1986 : states[pFeatures[index]] = xStates;</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 1986 : }</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 318 : const torch::Tensor weights = torch::full({ pDataset.size(1) }, 1.0 / pDataset.size(1), torch::kDouble);</span></span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 318 : model.fit(pDataset, weights, pFeatures, pClassName, states);</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 318 : }</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 636 : return states;</span></span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 1440192 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 348 : map&lt;std::string, std::vector&lt;int&gt;&gt; Proposal::fit_local_discretization(const torch::Tensor&amp; y)</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 662 : states[pFeatures[index]] = xStates;</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 662 : }</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 106 : const torch::Tensor weights = torch::full({ pDataset.size(1) }, 1.0 / pDataset.size(1), torch::kDouble);</span></span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 106 : model.fit(pDataset, weights, pFeatures, pClassName, states);</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 106 : }</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 212 : return states;</span></span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 480064 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 116 : map&lt;std::string, std::vector&lt;int&gt;&gt; Proposal::fit_local_discretization(const torch::Tensor&amp; y)</span></span>
<span id="L80"><span class="lineNum"> 80</span> : {</span>
<span id="L81"><span class="lineNum"> 81</span> : // Discretize the continuous input data and build pDataset (Classifier::dataset)</span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 348 : int m = Xf.size(1);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 348 : int n = Xf.size(0);</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 348 : map&lt;std::string, std::vector&lt;int&gt;&gt; states;</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 348 : pDataset = torch::zeros({ n + 1, m }, torch::kInt32);</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 348 : auto yv = std::vector&lt;int&gt;(y.data_ptr&lt;int&gt;(), y.data_ptr&lt;int&gt;() + y.size(0));</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 116 : int m = Xf.size(1);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 116 : int n = Xf.size(0);</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 116 : map&lt;std::string, std::vector&lt;int&gt;&gt; states;</span></span>
<span id="L85"><span class="lineNum"> 85</span> <span class="tlaGNC"> 116 : pDataset = torch::zeros({ n + 1, m }, torch::kInt32);</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 116 : auto yv = std::vector&lt;int&gt;(y.data_ptr&lt;int&gt;(), y.data_ptr&lt;int&gt;() + y.size(0));</span></span>
<span id="L87"><span class="lineNum"> 87</span> : // discretize input data by feature(row)</span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 2916 : for (auto i = 0; i &lt; pFeatures.size(); ++i) {</span></span>
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 2568 : auto* discretizer = new mdlp::CPPFImdlp();</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 5136 : auto Xt_ptr = Xf.index({ i }).data_ptr&lt;float&gt;();</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 2568 : auto Xt = std::vector&lt;float&gt;(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 2568 : discretizer-&gt;fit(Xt, yv);</span></span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 10272 : pDataset.index_put_({ i, &quot;...&quot; }, torch::tensor(discretizer-&gt;transform(Xt)));</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 2568 : auto xStates = std::vector&lt;int&gt;(discretizer-&gt;getCutPoints().size() + 1);</span></span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 2568 : iota(xStates.begin(), xStates.end(), 0);</span></span>
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 2568 : states[pFeatures[i]] = xStates;</span></span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 2568 : discretizers[pFeatures[i]] = discretizer;</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 2568 : }</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 348 : int n_classes = torch::max(y).item&lt;int&gt;() + 1;</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 348 : auto yStates = std::vector&lt;int&gt;(n_classes);</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 348 : iota(yStates.begin(), yStates.end(), 0);</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 348 : states[pClassName] = yStates;</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 1044 : pDataset.index_put_({ n, &quot;...&quot; }, y);</span></span>
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 696 : return states;</span></span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 5832 : }</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 252 : torch::Tensor Proposal::prepareX(torch::Tensor&amp; X)</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 972 : for (auto i = 0; i &lt; pFeatures.size(); ++i) {</span></span>
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 856 : auto* discretizer = new mdlp::CPPFImdlp();</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 1712 : auto Xt_ptr = Xf.index({ i }).data_ptr&lt;float&gt;();</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 856 : auto Xt = std::vector&lt;float&gt;(Xt_ptr, Xt_ptr + Xf.size(1));</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 856 : discretizer-&gt;fit(Xt, yv);</span></span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 3424 : pDataset.index_put_({ i, &quot;...&quot; }, torch::tensor(discretizer-&gt;transform(Xt)));</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 856 : auto xStates = std::vector&lt;int&gt;(discretizer-&gt;getCutPoints().size() + 1);</span></span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 856 : iota(xStates.begin(), xStates.end(), 0);</span></span>
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 856 : states[pFeatures[i]] = xStates;</span></span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 856 : discretizers[pFeatures[i]] = discretizer;</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 856 : }</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 116 : int n_classes = torch::max(y).item&lt;int&gt;() + 1;</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 116 : auto yStates = std::vector&lt;int&gt;(n_classes);</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 116 : iota(yStates.begin(), yStates.end(), 0);</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 116 : states[pClassName] = yStates;</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 348 : pDataset.index_put_({ n, &quot;...&quot; }, y);</span></span>
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 232 : return states;</span></span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 1944 : }</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 84 : torch::Tensor Proposal::prepareX(torch::Tensor&amp; X)</span></span>
<span id="L107"><span class="lineNum"> 107</span> : {</span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 252 : auto Xtd = torch::zeros_like(X, torch::kInt32);</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 2064 : for (int i = 0; i &lt; X.size(0); ++i) {</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 1812 : auto Xt = std::vector&lt;float&gt;(X[i].data_ptr&lt;float&gt;(), X[i].data_ptr&lt;float&gt;() + X.size(1));</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 1812 : auto Xd = discretizers[pFeatures[i]]-&gt;transform(Xt);</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 5436 : Xtd.index_put_({ i }, torch::tensor(Xd, torch::kInt32));</span></span>
<span id="L113"><span class="lineNum"> 113</span> <span class="tlaGNC"> 1812 : }</span></span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 252 : return Xtd;</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 1812 : }</span></span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 84 : auto Xtd = torch::zeros_like(X, torch::kInt32);</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 688 : for (int i = 0; i &lt; X.size(0); ++i) {</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 604 : auto Xt = std::vector&lt;float&gt;(X[i].data_ptr&lt;float&gt;(), X[i].data_ptr&lt;float&gt;() + X.size(1));</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 604 : auto Xd = discretizers[pFeatures[i]]-&gt;transform(Xt);</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 1812 : Xtd.index_put_({ i }, torch::tensor(Xd, torch::kInt32));</span></span>
<span id="L113"><span class="lineNum"> 113</span> <span class="tlaGNC"> 604 : }</span></span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 84 : return Xtd;</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 604 : }</span></span>
<span id="L116"><span class="lineNum"> 116</span> : }</span>
</pre>
</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,21 +65,21 @@
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L24">bayesnet::SPODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L11">bayesnet::SPODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1524</td>
<td class="coverFnHi">508</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">bayesnet::SPODE::SPODE(int)</a></td>
<td class="coverFnHi">1686</td>
<td class="coverFnHi">562</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,21 +65,21 @@
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L9">bayesnet::SPODE::SPODE(int)</a></td>
<td class="coverFnHi">1686</td>
<td class="coverFnHi">562</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L11">bayesnet::SPODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">1524</td>
<td class="coverFnHi">508</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODE.cc.gcov.html#L24">bayesnet::SPODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -70,24 +70,24 @@
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> : </span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 1686 : SPODE::SPODE(int root) : Classifier(Network()), root(root) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 562 : SPODE::SPODE(int root) : Classifier(Network()), root(root) {}</span></span>
<span id="L12"><span class="lineNum"> 12</span> : </span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 1524 : void SPODE::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 508 : void SPODE::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L14"><span class="lineNum"> 14</span> : {</span>
<span id="L15"><span class="lineNum"> 15</span> : // 0. Add all nodes to the model</span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 1524 : addNodes();</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 508 : addNodes();</span></span>
<span id="L17"><span class="lineNum"> 17</span> : // 1. Add edges from the class node to all other nodes</span>
<span id="L18"><span class="lineNum"> 18</span> : // 2. Add edges from the root node to all other nodes</span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 38520 : for (int i = 0; i &lt; static_cast&lt;int&gt;(features.size()); ++i) {</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 36996 : model.addEdge(className, features[i]);</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 36996 : if (i != root) {</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 35472 : model.addEdge(features[root], features[i]);</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 12840 : for (int i = 0; i &lt; static_cast&lt;int&gt;(features.size()); ++i) {</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 12332 : model.addEdge(className, features[i]);</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 12332 : if (i != root) {</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 11824 : model.addEdge(features[root], features[i]);</span></span>
<span id="L23"><span class="lineNum"> 23</span> : }</span>
<span id="L24"><span class="lineNum"> 24</span> : }</span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 1524 : }</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 102 : std::vector&lt;std::string&gt; SPODE::graph(const std::string&amp; name) const</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 508 : }</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 34 : std::vector&lt;std::string&gt; SPODE::graph(const std::string&amp; name) const</span></span>
<span id="L27"><span class="lineNum"> 27</span> : {</span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 102 : return model.graph(name);</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 34 : return model.graph(name);</span></span>
<span id="L29"><span class="lineNum"> 29</span> : }</span>
<span id="L30"><span class="lineNum"> 30</span> : </span>
<span id="L31"><span class="lineNum"> 31</span> : }</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="SPODE.h.gcov.html#L17">bayesnet::SPODE::~SPODE()</a></td>
<td class="coverFnHi">2754</td>
<td class="coverFnHi">918</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="SPODE.h.gcov.html#L17">bayesnet::SPODE::~SPODE()</a></td>
<td class="coverFnHi">2754</td>
<td class="coverFnHi">918</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -78,7 +78,7 @@
<span id="L16"><span class="lineNum"> 16</span> : void buildModel(const torch::Tensor&amp; weights) override;</span>
<span id="L17"><span class="lineNum"> 17</span> : public:</span>
<span id="L18"><span class="lineNum"> 18</span> : explicit SPODE(int root);</span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC tlaBgGNC"> 2754 : virtual ~SPODE() = default;</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC tlaBgGNC"> 918 : virtual ~SPODE() = default;</span></span>
<span id="L20"><span class="lineNum"> 20</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;SPODE&quot;) const override;</span>
<span id="L21"><span class="lineNum"> 21</span> : };</span>
<span id="L22"><span class="lineNum"> 22</span> : }</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,42 +65,42 @@
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L17">bayesnet::SPODELd::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L44">bayesnet::SPODELd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">54</td>
<td class="coverFnHi">18</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L39">bayesnet::SPODELd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">204</td>
<td class="coverFnHi">68</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L9">bayesnet::SPODELd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">252</td>
<td class="coverFnHi">84</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L27">bayesnet::SPODELd::commonFit(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">258</td>
<td class="coverFnHi">86</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L8">bayesnet::SPODELd::SPODELd(int)</a></td>
<td class="coverFnHi">330</td>
<td class="coverFnHi">110</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,42 +65,42 @@
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L8">bayesnet::SPODELd::SPODELd(int)</a></td>
<td class="coverFnHi">330</td>
<td class="coverFnHi">110</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L27">bayesnet::SPODELd::commonFit(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">258</td>
<td class="coverFnHi">86</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L9">bayesnet::SPODELd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">252</td>
<td class="coverFnHi">84</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L17">bayesnet::SPODELd::fit(at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L44">bayesnet::SPODELd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">54</td>
<td class="coverFnHi">18</td>
</tr>
<tr>
<td class="coverFn"><a href="SPODELd.cc.gcov.html#L39">bayesnet::SPODELd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">204</td>
<td class="coverFnHi">68</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -69,45 +69,45 @@
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;SPODELd.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 330 : SPODELd::SPODELd(int root) : SPODE(root), Proposal(dataset, features, className) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 252 : SPODELd&amp; SPODELd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 110 : SPODELd::SPODELd(int root) : SPODE(root), Proposal(dataset, features, className) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 84 : SPODELd&amp; SPODELd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L12"><span class="lineNum"> 12</span> : {</span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 252 : checkInput(X_, y_);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 252 : Xf = X_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 252 : y = y_;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 252 : return commonFit(features_, className_, states_);</span></span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 84 : checkInput(X_, y_);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 84 : Xf = X_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 84 : y = y_;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 84 : return commonFit(features_, className_, states_);</span></span>
<span id="L17"><span class="lineNum"> 17</span> : }</span>
<span id="L18"><span class="lineNum"> 18</span> : </span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 12 : SPODELd&amp; SPODELd::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 4 : SPODELd&amp; SPODELd::fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L20"><span class="lineNum"> 20</span> : {</span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 12 : if (!torch::is_floating_point(dataset)) {</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 6 : throw std::runtime_error(&quot;Dataset must be a floating point tensor&quot;);</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 4 : if (!torch::is_floating_point(dataset)) {</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 2 : throw std::runtime_error(&quot;Dataset must be a floating point tensor&quot;);</span></span>
<span id="L23"><span class="lineNum"> 23</span> : }</span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 24 : Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), &quot;...&quot; }).clone();</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 18 : y = dataset.index({ -1, &quot;...&quot; }).clone().to(torch::kInt32);</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 6 : return commonFit(features_, className_, states_);</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 18 : }</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 8 : Xf = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), &quot;...&quot; }).clone();</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 6 : y = dataset.index({ -1, &quot;...&quot; }).clone().to(torch::kInt32);</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 2 : return commonFit(features_, className_, states_);</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 6 : }</span></span>
<span id="L28"><span class="lineNum"> 28</span> : </span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 258 : SPODELd&amp; SPODELd::commonFit(const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 86 : SPODELd&amp; SPODELd::commonFit(const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L30"><span class="lineNum"> 30</span> : {</span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 258 : features = features_;</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 258 : className = className_;</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 86 : features = features_;</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 86 : className = className_;</span></span>
<span id="L33"><span class="lineNum"> 33</span> : // Fills std::vectors Xv &amp; yv with the data from tensors X_ (discretized) &amp; y</span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 258 : states = fit_local_discretization(y);</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 86 : states = fit_local_discretization(y);</span></span>
<span id="L35"><span class="lineNum"> 35</span> : // We have discretized the input data</span>
<span id="L36"><span class="lineNum"> 36</span> : // 1st we need to fit the model to build the normal SPODE structure, SPODE::fit initializes the base Bayesian network</span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 258 : SPODE::fit(dataset, features, className, states);</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 258 : states = localDiscretizationProposal(states, model);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 258 : return *this;</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 86 : SPODE::fit(dataset, features, className, states);</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 86 : states = localDiscretizationProposal(states, model);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 86 : return *this;</span></span>
<span id="L40"><span class="lineNum"> 40</span> : }</span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 204 : torch::Tensor SPODELd::predict(torch::Tensor&amp; X)</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 68 : torch::Tensor SPODELd::predict(torch::Tensor&amp; X)</span></span>
<span id="L42"><span class="lineNum"> 42</span> : {</span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 204 : auto Xt = prepareX(X);</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 408 : return SPODE::predict(Xt);</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 204 : }</span></span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 54 : std::vector&lt;std::string&gt; SPODELd::graph(const std::string&amp; name) const</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 68 : auto Xt = prepareX(X);</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 136 : return SPODE::predict(Xt);</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 68 : }</span></span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 18 : std::vector&lt;std::string&gt; SPODELd::graph(const std::string&amp; name) const</span></span>
<span id="L47"><span class="lineNum"> 47</span> : {</span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 54 : return SPODE::graph(name);</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 18 : return SPODE::graph(name);</span></span>
<span id="L49"><span class="lineNum"> 49</span> : }</span>
<span id="L50"><span class="lineNum"> 50</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="SPODELd.h.gcov.html#L14">bayesnet::SPODELd::~SPODELd()</a></td>
<td class="coverFnHi">480</td>
<td class="coverFnHi">160</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="SPODELd.h.gcov.html#L14">bayesnet::SPODELd::~SPODELd()</a></td>
<td class="coverFnHi">480</td>
<td class="coverFnHi">160</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -75,7 +75,7 @@
<span id="L13"><span class="lineNum"> 13</span> : class SPODELd : public SPODE, public Proposal {</span>
<span id="L14"><span class="lineNum"> 14</span> : public:</span>
<span id="L15"><span class="lineNum"> 15</span> : explicit SPODELd(int root);</span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC tlaBgGNC"> 480 : virtual ~SPODELd() = default;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC tlaBgGNC"> 160 : virtual ~SPODELd() = default;</span></span>
<span id="L17"><span class="lineNum"> 17</span> : SPODELd&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L18"><span class="lineNum"> 18</span> : SPODELd&amp; fit(torch::Tensor&amp; dataset, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L19"><span class="lineNum"> 19</span> : SPODELd&amp; commonFit(const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states);</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L39">bayesnet::TAN::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L10">bayesnet::TAN::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">78</td>
<td class="coverFnHi">26</td>
</tr>
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L8">bayesnet::TAN::TAN()</a></td>
<td class="coverFnHi">282</td>
<td class="coverFnHi">94</td>
</tr>
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L23">auto bayesnet::TAN::buildModel(at::Tensor const&amp;)::{lambda(auto:1 const&amp;, auto:2 const&amp;)#1}::operator()&lt;std::pair&lt;int, float&gt;, std::pair&lt;int, float&gt; &gt;(std::pair&lt;int, float&gt; const&amp;, std::pair&lt;int, float&gt; const&amp;) const</a></td>
<td class="coverFnHi">972</td>
<td class="coverFnHi">324</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L23">auto bayesnet::TAN::buildModel(at::Tensor const&amp;)::{lambda(auto:1 const&amp;, auto:2 const&amp;)#1}::operator()&lt;std::pair&lt;int, float&gt;, std::pair&lt;int, float&gt; &gt;(std::pair&lt;int, float&gt; const&amp;, std::pair&lt;int, float&gt; const&amp;) const</a></td>
<td class="coverFnHi">972</td>
<td class="coverFnHi">324</td>
</tr>
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L8">bayesnet::TAN::TAN()</a></td>
<td class="coverFnHi">282</td>
<td class="coverFnHi">94</td>
</tr>
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L10">bayesnet::TAN::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">78</td>
<td class="coverFnHi">26</td>
</tr>
<tr>
<td class="coverFn"><a href="TAN.cc.gcov.html#L39">bayesnet::TAN::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -69,40 +69,40 @@
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;TAN.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 282 : TAN::TAN() : Classifier(Network()) {}</span></span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 94 : TAN::TAN() : Classifier(Network()) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> : </span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 78 : void TAN::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 26 : void TAN::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L13"><span class="lineNum"> 13</span> : {</span>
<span id="L14"><span class="lineNum"> 14</span> : // 0. Add all nodes to the model</span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 78 : addNodes();</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 26 : addNodes();</span></span>
<span id="L16"><span class="lineNum"> 16</span> : // 1. Compute mutual information between each feature and the class and set the root node</span>
<span id="L17"><span class="lineNum"> 17</span> : // as the highest mutual information with the class</span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 78 : auto mi = std::vector &lt;std::pair&lt;int, float &gt;&gt;();</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 234 : torch::Tensor class_dataset = dataset.index({ -1, &quot;...&quot; });</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 534 : for (int i = 0; i &lt; static_cast&lt;int&gt;(features.size()); ++i) {</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 1368 : torch::Tensor feature_dataset = dataset.index({ i, &quot;...&quot; });</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 456 : auto mi_value = metrics.mutualInformation(class_dataset, feature_dataset, weights);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 456 : mi.push_back({ i, mi_value });</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 456 : }</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 1050 : sort(mi.begin(), mi.end(), [](const auto&amp; left, const auto&amp; right) {return left.second &lt; right.second;});</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 78 : auto root = mi[mi.size() - 1].first;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 26 : auto mi = std::vector &lt;std::pair&lt;int, float &gt;&gt;();</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 78 : torch::Tensor class_dataset = dataset.index({ -1, &quot;...&quot; });</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 178 : for (int i = 0; i &lt; static_cast&lt;int&gt;(features.size()); ++i) {</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 456 : torch::Tensor feature_dataset = dataset.index({ i, &quot;...&quot; });</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 152 : auto mi_value = metrics.mutualInformation(class_dataset, feature_dataset, weights);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 152 : mi.push_back({ i, mi_value });</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 152 : }</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 350 : sort(mi.begin(), mi.end(), [](const auto&amp; left, const auto&amp; right) {return left.second &lt; right.second;});</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 26 : auto root = mi[mi.size() - 1].first;</span></span>
<span id="L27"><span class="lineNum"> 27</span> : // 2. Compute mutual information between each feature and the class</span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 78 : auto weights_matrix = metrics.conditionalEdge(weights);</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 26 : auto weights_matrix = metrics.conditionalEdge(weights);</span></span>
<span id="L29"><span class="lineNum"> 29</span> : // 3. Compute the maximum spanning tree</span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 78 : auto mst = metrics.maximumSpanningTree(features, weights_matrix, root);</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 26 : auto mst = metrics.maximumSpanningTree(features, weights_matrix, root);</span></span>
<span id="L31"><span class="lineNum"> 31</span> : // 4. Add edges from the maximum spanning tree to the model</span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 456 : for (auto i = 0; i &lt; mst.size(); ++i) {</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 378 : auto [from, to] = mst[i];</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 378 : model.addEdge(features[from], features[to]);</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 152 : for (auto i = 0; i &lt; mst.size(); ++i) {</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 126 : auto [from, to] = mst[i];</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 126 : model.addEdge(features[from], features[to]);</span></span>
<span id="L35"><span class="lineNum"> 35</span> : }</span>
<span id="L36"><span class="lineNum"> 36</span> : // 5. Add edges from the class to all features</span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 534 : for (auto feature : features) {</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 456 : model.addEdge(className, feature);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 456 : }</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 612 : }</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 12 : std::vector&lt;std::string&gt; TAN::graph(const std::string&amp; title) const</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 178 : for (auto feature : features) {</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 152 : model.addEdge(className, feature);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 152 : }</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 204 : }</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 4 : std::vector&lt;std::string&gt; TAN::graph(const std::string&amp; title) const</span></span>
<span id="L42"><span class="lineNum"> 42</span> : {</span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 12 : return model.graph(title);</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 4 : return model.graph(title);</span></span>
<span id="L44"><span class="lineNum"> 44</span> : }</span>
<span id="L45"><span class="lineNum"> 45</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="TAN.h.gcov.html#L15">bayesnet::TAN::~TAN()</a></td>
<td class="coverFnHi">114</td>
<td class="coverFnHi">38</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="TAN.h.gcov.html#L15">bayesnet::TAN::~TAN()</a></td>
<td class="coverFnHi">114</td>
<td class="coverFnHi">38</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -76,7 +76,7 @@
<span id="L14"><span class="lineNum"> 14</span> : void buildModel(const torch::Tensor&amp; weights) override;</span>
<span id="L15"><span class="lineNum"> 15</span> : public:</span>
<span id="L16"><span class="lineNum"> 16</span> : TAN();</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 114 : virtual ~TAN() = default;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 38 : virtual ~TAN() = default;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;TAN&quot;) const override;</span>
<span id="L19"><span class="lineNum"> 19</span> : };</span>
<span id="L20"><span class="lineNum"> 20</span> : }</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L30">bayesnet::TANLd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L25">bayesnet::TANLd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L9">bayesnet::TANLd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L8">bayesnet::TANLd::TANLd()</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L8">bayesnet::TANLd::TANLd()</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L9">bayesnet::TANLd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L30">bayesnet::TANLd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="TANLd.cc.gcov.html#L25">bayesnet::TANLd::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">24</td>
<td class="coverFnHi">8</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -69,31 +69,31 @@
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;TANLd.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 102 : TANLd::TANLd() : TAN(), Proposal(dataset, features, className) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 30 : TANLd&amp; TANLd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 34 : TANLd::TANLd() : TAN(), Proposal(dataset, features, className) {}</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC"> 10 : TANLd&amp; TANLd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L12"><span class="lineNum"> 12</span> : {</span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 30 : checkInput(X_, y_);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 30 : features = features_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 30 : className = className_;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 30 : Xf = X_;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 30 : y = y_;</span></span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 10 : checkInput(X_, y_);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 10 : features = features_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 10 : className = className_;</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 10 : Xf = X_;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 10 : y = y_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : // Fills std::vectors Xv &amp; yv with the data from tensors X_ (discretized) &amp; y</span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 30 : states = fit_local_discretization(y);</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 10 : states = fit_local_discretization(y);</span></span>
<span id="L20"><span class="lineNum"> 20</span> : // We have discretized the input data</span>
<span id="L21"><span class="lineNum"> 21</span> : // 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 30 : TAN::fit(dataset, features, className, states);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 30 : states = localDiscretizationProposal(states, model);</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 30 : return *this;</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 10 : TAN::fit(dataset, features, className, states);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 10 : states = localDiscretizationProposal(states, model);</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 10 : return *this;</span></span>
<span id="L25"><span class="lineNum"> 25</span> : </span>
<span id="L26"><span class="lineNum"> 26</span> : }</span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 24 : torch::Tensor TANLd::predict(torch::Tensor&amp; X)</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 8 : torch::Tensor TANLd::predict(torch::Tensor&amp; X)</span></span>
<span id="L28"><span class="lineNum"> 28</span> : {</span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 24 : auto Xt = prepareX(X);</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 48 : return TAN::predict(Xt);</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 24 : }</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; TANLd::graph(const std::string&amp; name) const</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 8 : auto Xt = prepareX(X);</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 16 : return TAN::predict(Xt);</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 8 : }</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 2 : std::vector&lt;std::string&gt; TANLd::graph(const std::string&amp; name) const</span></span>
<span id="L33"><span class="lineNum"> 33</span> : {</span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 6 : return TAN::graph(name);</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 2 : return TAN::graph(name);</span></span>
<span id="L35"><span class="lineNum"> 35</span> : }</span>
<span id="L36"><span class="lineNum"> 36</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="TANLd.h.gcov.html#L15">bayesnet::TANLd::~TANLd()</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="TANLd.h.gcov.html#L15">bayesnet::TANLd::~TANLd()</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -76,7 +76,7 @@
<span id="L14"><span class="lineNum"> 14</span> : private:</span>
<span id="L15"><span class="lineNum"> 15</span> : public:</span>
<span id="L16"><span class="lineNum"> 16</span> : TANLd();</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 30 : virtual ~TANLd() = default;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 10 : virtual ~TANLd() = default;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : TANLd&amp; fit(torch::Tensor&amp; X, torch::Tensor&amp; y, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states) override;</span>
<span id="L19"><span class="lineNum"> 19</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;TAN&quot;) const override;</span>
<span id="L20"><span class="lineNum"> 20</span> : torch::Tensor predict(torch::Tensor&amp; X) override;</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L32">bayesnet::AODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L13">bayesnet::AODE::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L22">bayesnet::AODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L8">bayesnet::AODE::AODE(bool)</a></td>
<td class="coverFnHi">114</td>
<td class="coverFnHi">38</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,28 +65,28 @@
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L8">bayesnet::AODE::AODE(bool)</a></td>
<td class="coverFnHi">114</td>
<td class="coverFnHi">38</td>
</tr>
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L22">bayesnet::AODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L32">bayesnet::AODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="AODE.cc.gcov.html#L13">bayesnet::AODE::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -69,33 +69,33 @@
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;AODE.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 114 : AODE::AODE(bool predict_voting) : Ensemble(predict_voting)</span></span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 38 : AODE::AODE(bool predict_voting) : Ensemble(predict_voting)</span></span>
<span id="L11"><span class="lineNum"> 11</span> : {</span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 228 : validHyperparameters = { &quot;predict_voting&quot; };</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 76 : validHyperparameters = { &quot;predict_voting&quot; };</span></span>
<span id="L13"><span class="lineNum"> 13</span> : </span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 342 : }</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 6 : void AODE::setHyperparameters(const nlohmann::json&amp; hyperparameters_)</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 114 : }</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 2 : void AODE::setHyperparameters(const nlohmann::json&amp; hyperparameters_)</span></span>
<span id="L16"><span class="lineNum"> 16</span> : {</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 6 : auto hyperparameters = hyperparameters_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 6 : if (hyperparameters.contains(&quot;predict_voting&quot;)) {</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 6 : predict_voting = hyperparameters[&quot;predict_voting&quot;];</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 6 : hyperparameters.erase(&quot;predict_voting&quot;);</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 2 : auto hyperparameters = hyperparameters_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 2 : if (hyperparameters.contains(&quot;predict_voting&quot;)) {</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 2 : predict_voting = hyperparameters[&quot;predict_voting&quot;];</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 2 : hyperparameters.erase(&quot;predict_voting&quot;);</span></span>
<span id="L21"><span class="lineNum"> 21</span> : }</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 6 : Classifier::setHyperparameters(hyperparameters);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 6 : }</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 36 : void AODE::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 2 : Classifier::setHyperparameters(hyperparameters);</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 2 : }</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 12 : void AODE::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L25"><span class="lineNum"> 25</span> : {</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 36 : models.clear();</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 36 : significanceModels.clear();</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 282 : for (int i = 0; i &lt; features.size(); ++i) {</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 246 : models.push_back(std::make_unique&lt;SPODE&gt;(i));</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 12 : models.clear();</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 12 : significanceModels.clear();</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 94 : for (int i = 0; i &lt; features.size(); ++i) {</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 82 : models.push_back(std::make_unique&lt;SPODE&gt;(i));</span></span>
<span id="L30"><span class="lineNum"> 30</span> : }</span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 36 : n_models = models.size();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 36 : significanceModels = std::vector&lt;double&gt;(n_models, 1.0);</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 36 : }</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; AODE::graph(const std::string&amp; title) const</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 12 : n_models = models.size();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 12 : significanceModels = std::vector&lt;double&gt;(n_models, 1.0);</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 12 : }</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 2 : std::vector&lt;std::string&gt; AODE::graph(const std::string&amp; title) const</span></span>
<span id="L35"><span class="lineNum"> 35</span> : {</span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 6 : return Ensemble::graph(title);</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 2 : return Ensemble::graph(title);</span></span>
<span id="L37"><span class="lineNum"> 37</span> : }</span>
<span id="L38"><span class="lineNum"> 38</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="AODE.h.gcov.html#L13">bayesnet::AODE::~AODE()</a></td>
<td class="coverFnHi">42</td>
<td class="coverFnHi">14</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="AODE.h.gcov.html#L13">bayesnet::AODE::~AODE()</a></td>
<td class="coverFnHi">42</td>
<td class="coverFnHi">14</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -74,7 +74,7 @@
<span id="L12"><span class="lineNum"> 12</span> : class AODE : public Ensemble {</span>
<span id="L13"><span class="lineNum"> 13</span> : public:</span>
<span id="L14"><span class="lineNum"> 14</span> : AODE(bool predict_voting = false);</span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC tlaBgGNC"> 42 : virtual ~AODE() {};</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC tlaBgGNC"> 14 : virtual ~AODE() {};</span></span>
<span id="L16"><span class="lineNum"> 16</span> : void setHyperparameters(const nlohmann::json&amp; hyperparameters) override;</span>
<span id="L17"><span class="lineNum"> 17</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; title = &quot;AODE&quot;) const override;</span>
<span id="L18"><span class="lineNum"> 18</span> : protected:</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,35 +65,35 @@
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L41">bayesnet::AODELd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L26">bayesnet::AODELd::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L11">bayesnet::AODELd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L35">bayesnet::AODELd::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L8">bayesnet::AODELd::AODELd(bool)</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,35 +65,35 @@
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L8">bayesnet::AODELd::AODELd(bool)</a></td>
<td class="coverFnHi">102</td>
<td class="coverFnHi">34</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L26">bayesnet::AODELd::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L11">bayesnet::AODELd::fit(at::Tensor&amp;, at::Tensor&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L41">bayesnet::AODELd::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="AODELd.cc.gcov.html#L35">bayesnet::AODELd::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -69,42 +69,42 @@
<span id="L7"><span class="lineNum"> 7</span> : #include &quot;AODELd.h&quot;</span>
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 102 : AODELd::AODELd(bool predict_voting) : Ensemble(predict_voting), Proposal(dataset, features, className)</span></span>
<span id="L10"><span class="lineNum"> 10</span> <span class="tlaGNC tlaBgGNC"> 34 : AODELd::AODELd(bool predict_voting) : Ensemble(predict_voting), Proposal(dataset, features, className)</span></span>
<span id="L11"><span class="lineNum"> 11</span> : {</span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 102 : }</span></span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 30 : AODELd&amp; AODELd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 34 : }</span></span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 10 : AODELd&amp; AODELd::fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_)</span></span>
<span id="L14"><span class="lineNum"> 14</span> : {</span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 30 : checkInput(X_, y_);</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 30 : features = features_;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 30 : className = className_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 30 : Xf = X_;</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 30 : y = y_;</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 10 : checkInput(X_, y_);</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 10 : features = features_;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 10 : className = className_;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 10 : Xf = X_;</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 10 : y = y_;</span></span>
<span id="L20"><span class="lineNum"> 20</span> : // Fills std::vectors Xv &amp; yv with the data from tensors X_ (discretized) &amp; y</span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 30 : states = fit_local_discretization(y);</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 10 : states = fit_local_discretization(y);</span></span>
<span id="L22"><span class="lineNum"> 22</span> : // We have discretized the input data</span>
<span id="L23"><span class="lineNum"> 23</span> : // 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network</span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 30 : Ensemble::fit(dataset, features, className, states);</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 30 : return *this;</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 10 : Ensemble::fit(dataset, features, className, states);</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 10 : return *this;</span></span>
<span id="L26"><span class="lineNum"> 26</span> : </span>
<span id="L27"><span class="lineNum"> 27</span> : }</span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 30 : void AODELd::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 10 : void AODELd::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L29"><span class="lineNum"> 29</span> : {</span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 30 : models.clear();</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 252 : for (int i = 0; i &lt; features.size(); ++i) {</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 222 : models.push_back(std::make_unique&lt;SPODELd&gt;(i));</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 10 : models.clear();</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 84 : for (int i = 0; i &lt; features.size(); ++i) {</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 74 : models.push_back(std::make_unique&lt;SPODELd&gt;(i));</span></span>
<span id="L33"><span class="lineNum"> 33</span> : }</span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 30 : n_models = models.size();</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 30 : significanceModels = std::vector&lt;double&gt;(n_models, 1.0);</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 30 : }</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 30 : void AODELd::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 10 : n_models = models.size();</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 10 : significanceModels = std::vector&lt;double&gt;(n_models, 1.0);</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 10 : }</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 10 : void AODELd::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L38"><span class="lineNum"> 38</span> : {</span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 252 : for (const auto&amp; model : models) {</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 222 : model-&gt;fit(Xf, y, features, className, states);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 84 : for (const auto&amp; model : models) {</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 74 : model-&gt;fit(Xf, y, features, className, states);</span></span>
<span id="L41"><span class="lineNum"> 41</span> : }</span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 30 : }</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; AODELd::graph(const std::string&amp; name) const</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 10 : }</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 2 : std::vector&lt;std::string&gt; AODELd::graph(const std::string&amp; name) const</span></span>
<span id="L44"><span class="lineNum"> 44</span> : {</span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 6 : return Ensemble::graph(name);</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 2 : return Ensemble::graph(name);</span></span>
<span id="L46"><span class="lineNum"> 46</span> : }</span>
<span id="L47"><span class="lineNum"> 47</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="AODELd.h.gcov.html#L15">bayesnet::AODELd::~AODELd()</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="AODELd.h.gcov.html#L15">bayesnet::AODELd::~AODELd()</a></td>
<td class="coverFnHi">30</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -76,7 +76,7 @@
<span id="L14"><span class="lineNum"> 14</span> : class AODELd : public Ensemble, public Proposal {</span>
<span id="L15"><span class="lineNum"> 15</span> : public:</span>
<span id="L16"><span class="lineNum"> 16</span> : AODELd(bool predict_voting = true);</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 30 : virtual ~AODELd() = default;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 10 : virtual ~AODELd() = default;</span></span>
<span id="L18"><span class="lineNum"> 18</span> : AODELd&amp; fit(torch::Tensor&amp; X_, torch::Tensor&amp; y_, const std::vector&lt;std::string&gt;&amp; features_, const std::string&amp; className_, map&lt;std::string, std::vector&lt;int&gt;&gt;&amp; states_) override;</span>
<span id="L19"><span class="lineNum"> 19</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; name = &quot;AODELd&quot;) const override;</span>
<span id="L20"><span class="lineNum"> 20</span> : protected:</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,63 +65,63 @@
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L390">bayesnet::BoostAODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L137">bayesnet::BoostAODE::update_weights_block(int, at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">42</td>
<td class="coverFnHi">14</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L233">bayesnet::BoostAODE::initializeModels()</a></td>
<td class="coverFnHi">48</td>
<td class="coverFnHi">16</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L57">bayesnet::BoostAODE::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">132</td>
<td class="coverFnHi">44</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L26">bayesnet::BoostAODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">138</td>
<td class="coverFnHi">46</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L266">bayesnet::BoostAODE::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">138</td>
<td class="coverFnHi">46</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L18">bayesnet::BoostAODE::BoostAODE(bool)</a></td>
<td class="coverFnHi">252</td>
<td class="coverFnHi">84</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L110">bayesnet::update_weights(at::Tensor&amp;, at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">816</td>
<td class="coverFnHi">272</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L313">auto bayesnet::BoostAODE::trainModel(at::Tensor const&amp;)::{lambda(auto:1)#1}::operator()&lt;int&gt;(int) const</a></td>
<td class="coverFnHi">14550</td>
<td class="coverFnHi">4850</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,63 +65,63 @@
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L313">auto bayesnet::BoostAODE::trainModel(at::Tensor const&amp;)::{lambda(auto:1)#1}::operator()&lt;int&gt;(int) const</a></td>
<td class="coverFnHi">14550</td>
<td class="coverFnHi">4850</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L18">bayesnet::BoostAODE::BoostAODE(bool)</a></td>
<td class="coverFnHi">252</td>
<td class="coverFnHi">84</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L26">bayesnet::BoostAODE::buildModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">138</td>
<td class="coverFnHi">46</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L390">bayesnet::BoostAODE::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L233">bayesnet::BoostAODE::initializeModels()</a></td>
<td class="coverFnHi">48</td>
<td class="coverFnHi">16</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L57">bayesnet::BoostAODE::setHyperparameters(nlohmann::json_abi_v3_11_3::basic_json&lt;std::map, std::vector, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::vector&lt;unsigned char, std::allocator&lt;unsigned char&gt; &gt;, void&gt; const&amp;)</a></td>
<td class="coverFnHi">132</td>
<td class="coverFnHi">44</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L266">bayesnet::BoostAODE::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">138</td>
<td class="coverFnHi">46</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L137">bayesnet::BoostAODE::update_weights_block(int, at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">42</td>
<td class="coverFnHi">14</td>
</tr>
<tr>
<td class="coverFn"><a href="BoostAODE.cc.gcov.html#L110">bayesnet::update_weights(at::Tensor&amp;, at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">816</td>
<td class="coverFnHi">272</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -79,126 +79,126 @@
<span id="L17"><span class="lineNum"> 17</span> : </span>
<span id="L18"><span class="lineNum"> 18</span> : namespace bayesnet {</span>
<span id="L19"><span class="lineNum"> 19</span> : </span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC tlaBgGNC"> 252 : BoostAODE::BoostAODE(bool predict_voting) : Ensemble(predict_voting)</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC tlaBgGNC"> 84 : BoostAODE::BoostAODE(bool predict_voting) : Ensemble(predict_voting)</span></span>
<span id="L21"><span class="lineNum"> 21</span> : {</span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 2772 : validHyperparameters = {</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 924 : validHyperparameters = {</span></span>
<span id="L23"><span class="lineNum"> 23</span> : &quot;maxModels&quot;, &quot;bisection&quot;, &quot;order&quot;, &quot;convergence&quot;, &quot;convergence_best&quot;, &quot;threshold&quot;,</span>
<span id="L24"><span class="lineNum"> 24</span> : &quot;select_features&quot;, &quot;maxTolerance&quot;, &quot;predict_voting&quot;, &quot;block_update&quot;</span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 2772 : };</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 924 : };</span></span>
<span id="L26"><span class="lineNum"> 26</span> : </span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 756 : }</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 138 : void BoostAODE::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 252 : }</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 46 : void BoostAODE::buildModel(const torch::Tensor&amp; weights)</span></span>
<span id="L29"><span class="lineNum"> 29</span> : {</span>
<span id="L30"><span class="lineNum"> 30</span> : // Models shall be built in trainModel</span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 138 : models.clear();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 138 : significanceModels.clear();</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 138 : n_models = 0;</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 46 : models.clear();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 46 : significanceModels.clear();</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 46 : n_models = 0;</span></span>
<span id="L34"><span class="lineNum"> 34</span> : // Prepare the validation dataset</span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 414 : auto y_ = dataset.index({ -1, &quot;...&quot; });</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 138 : if (convergence) {</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 138 : auto y_ = dataset.index({ -1, &quot;...&quot; });</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 46 : if (convergence) {</span></span>
<span id="L37"><span class="lineNum"> 37</span> : // Prepare train &amp; validation sets from train data</span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 114 : auto fold = folding::StratifiedKFold(5, y_, 271);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 114 : auto [train, test] = fold.getFold(0);</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 114 : auto train_t = torch::tensor(train);</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 114 : auto test_t = torch::tensor(test);</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 38 : auto fold = folding::StratifiedKFold(5, y_, 271);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 38 : auto [train, test] = fold.getFold(0);</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 38 : auto train_t = torch::tensor(train);</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 38 : auto test_t = torch::tensor(test);</span></span>
<span id="L42"><span class="lineNum"> 42</span> : // Get train and validation sets</span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 570 : X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), train_t });</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 342 : y_train = dataset.index({ -1, train_t });</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 570 : X_test = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), test_t });</span></span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 342 : y_test = dataset.index({ -1, test_t });</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 114 : dataset = X_train;</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 114 : m = X_train.size(1);</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 114 : auto n_classes = states.at(className).size();</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 190 : X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), train_t });</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 114 : y_train = dataset.index({ -1, train_t });</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 190 : X_test = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), test_t });</span></span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 114 : y_test = dataset.index({ -1, test_t });</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 38 : dataset = X_train;</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 38 : m = X_train.size(1);</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 38 : auto n_classes = states.at(className).size();</span></span>
<span id="L50"><span class="lineNum"> 50</span> : // Build dataset with train data</span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 114 : buildDataset(y_train);</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 114 : metrics = Metrics(dataset, features, className, n_classes);</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 114 : } else {</span></span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 38 : buildDataset(y_train);</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 38 : metrics = Metrics(dataset, features, className, n_classes);</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 38 : } else {</span></span>
<span id="L54"><span class="lineNum"> 54</span> : // Use all data to train</span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 96 : X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), &quot;...&quot; });</span></span>
<span id="L56"><span class="lineNum"> 56</span> <span class="tlaGNC"> 24 : y_train = y_;</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 32 : X_train = dataset.index({ torch::indexing::Slice(0, dataset.size(0) - 1), &quot;...&quot; });</span></span>
<span id="L56"><span class="lineNum"> 56</span> <span class="tlaGNC"> 8 : y_train = y_;</span></span>
<span id="L57"><span class="lineNum"> 57</span> : }</span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 1350 : }</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 132 : void BoostAODE::setHyperparameters(const nlohmann::json&amp; hyperparameters_)</span></span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 450 : }</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 44 : void BoostAODE::setHyperparameters(const nlohmann::json&amp; hyperparameters_)</span></span>
<span id="L60"><span class="lineNum"> 60</span> : {</span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 132 : auto hyperparameters = hyperparameters_;</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 132 : if (hyperparameters.contains(&quot;order&quot;)) {</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 150 : std::vector&lt;std::string&gt; algos = { Orders.ASC, Orders.DESC, Orders.RAND };</span></span>
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 30 : order_algorithm = hyperparameters[&quot;order&quot;];</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 30 : if (std::find(algos.begin(), algos.end(), order_algorithm) == algos.end()) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 6 : throw std::invalid_argument(&quot;Invalid order algorithm, valid values [&quot; + Orders.ASC + &quot;, &quot; + Orders.DESC + &quot;, &quot; + Orders.RAND + &quot;]&quot;);</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 44 : auto hyperparameters = hyperparameters_;</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 44 : if (hyperparameters.contains(&quot;order&quot;)) {</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 50 : std::vector&lt;std::string&gt; algos = { Orders.ASC, Orders.DESC, Orders.RAND };</span></span>
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 10 : order_algorithm = hyperparameters[&quot;order&quot;];</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 10 : if (std::find(algos.begin(), algos.end(), order_algorithm) == algos.end()) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 2 : throw std::invalid_argument(&quot;Invalid order algorithm, valid values [&quot; + Orders.ASC + &quot;, &quot; + Orders.DESC + &quot;, &quot; + Orders.RAND + &quot;]&quot;);</span></span>
<span id="L67"><span class="lineNum"> 67</span> : }</span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 24 : hyperparameters.erase(&quot;order&quot;);</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 30 : }</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 126 : if (hyperparameters.contains(&quot;convergence&quot;)) {</span></span>
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 54 : convergence = hyperparameters[&quot;convergence&quot;];</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 54 : hyperparameters.erase(&quot;convergence&quot;);</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 8 : hyperparameters.erase(&quot;order&quot;);</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 10 : }</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 42 : if (hyperparameters.contains(&quot;convergence&quot;)) {</span></span>
<span id="L71"><span class="lineNum"> 71</span> <span class="tlaGNC"> 18 : convergence = hyperparameters[&quot;convergence&quot;];</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 18 : hyperparameters.erase(&quot;convergence&quot;);</span></span>
<span id="L73"><span class="lineNum"> 73</span> : }</span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 126 : if (hyperparameters.contains(&quot;convergence_best&quot;)) {</span></span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 18 : convergence_best = hyperparameters[&quot;convergence_best&quot;];</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 18 : hyperparameters.erase(&quot;convergence_best&quot;);</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 42 : if (hyperparameters.contains(&quot;convergence_best&quot;)) {</span></span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 6 : convergence_best = hyperparameters[&quot;convergence_best&quot;];</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 6 : hyperparameters.erase(&quot;convergence_best&quot;);</span></span>
<span id="L77"><span class="lineNum"> 77</span> : }</span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 126 : if (hyperparameters.contains(&quot;bisection&quot;)) {</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 48 : bisection = hyperparameters[&quot;bisection&quot;];</span></span>
<span id="L80"><span class="lineNum"> 80</span> <span class="tlaGNC"> 48 : hyperparameters.erase(&quot;bisection&quot;);</span></span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 42 : if (hyperparameters.contains(&quot;bisection&quot;)) {</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 16 : bisection = hyperparameters[&quot;bisection&quot;];</span></span>
<span id="L80"><span class="lineNum"> 80</span> <span class="tlaGNC"> 16 : hyperparameters.erase(&quot;bisection&quot;);</span></span>
<span id="L81"><span class="lineNum"> 81</span> : }</span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 126 : if (hyperparameters.contains(&quot;threshold&quot;)) {</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 36 : threshold = hyperparameters[&quot;threshold&quot;];</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 36 : hyperparameters.erase(&quot;threshold&quot;);</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 42 : if (hyperparameters.contains(&quot;threshold&quot;)) {</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 12 : threshold = hyperparameters[&quot;threshold&quot;];</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 12 : hyperparameters.erase(&quot;threshold&quot;);</span></span>
<span id="L85"><span class="lineNum"> 85</span> : }</span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 126 : if (hyperparameters.contains(&quot;maxTolerance&quot;)) {</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 66 : maxTolerance = hyperparameters[&quot;maxTolerance&quot;];</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 66 : if (maxTolerance &lt; 1 || maxTolerance &gt; 4)</span></span>
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 18 : throw std::invalid_argument(&quot;Invalid maxTolerance value, must be greater in [1, 4]&quot;);</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 48 : hyperparameters.erase(&quot;maxTolerance&quot;);</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 42 : if (hyperparameters.contains(&quot;maxTolerance&quot;)) {</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 22 : maxTolerance = hyperparameters[&quot;maxTolerance&quot;];</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 22 : if (maxTolerance &lt; 1 || maxTolerance &gt; 4)</span></span>
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 6 : throw std::invalid_argument(&quot;Invalid maxTolerance value, must be greater in [1, 4]&quot;);</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 16 : hyperparameters.erase(&quot;maxTolerance&quot;);</span></span>
<span id="L91"><span class="lineNum"> 91</span> : }</span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 108 : if (hyperparameters.contains(&quot;predict_voting&quot;)) {</span></span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 6 : predict_voting = hyperparameters[&quot;predict_voting&quot;];</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 6 : hyperparameters.erase(&quot;predict_voting&quot;);</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 36 : if (hyperparameters.contains(&quot;predict_voting&quot;)) {</span></span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 2 : predict_voting = hyperparameters[&quot;predict_voting&quot;];</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 2 : hyperparameters.erase(&quot;predict_voting&quot;);</span></span>
<span id="L95"><span class="lineNum"> 95</span> : }</span>
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 108 : if (hyperparameters.contains(&quot;select_features&quot;)) {</span></span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 54 : auto selectedAlgorithm = hyperparameters[&quot;select_features&quot;];</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 270 : std::vector&lt;std::string&gt; algos = { SelectFeatures.IWSS, SelectFeatures.CFS, SelectFeatures.FCBF };</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 54 : selectFeatures = true;</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 54 : select_features_algorithm = selectedAlgorithm;</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 54 : if (std::find(algos.begin(), algos.end(), selectedAlgorithm) == algos.end()) {</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 6 : throw std::invalid_argument(&quot;Invalid selectFeatures value, valid values [&quot; + SelectFeatures.IWSS + &quot;, &quot; + SelectFeatures.CFS + &quot;, &quot; + SelectFeatures.FCBF + &quot;]&quot;);</span></span>
<span id="L96"><span class="lineNum"> 96</span> <span class="tlaGNC"> 36 : if (hyperparameters.contains(&quot;select_features&quot;)) {</span></span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 18 : auto selectedAlgorithm = hyperparameters[&quot;select_features&quot;];</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 90 : std::vector&lt;std::string&gt; algos = { SelectFeatures.IWSS, SelectFeatures.CFS, SelectFeatures.FCBF };</span></span>
<span id="L99"><span class="lineNum"> 99</span> <span class="tlaGNC"> 18 : selectFeatures = true;</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 18 : select_features_algorithm = selectedAlgorithm;</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 18 : if (std::find(algos.begin(), algos.end(), selectedAlgorithm) == algos.end()) {</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 2 : throw std::invalid_argument(&quot;Invalid selectFeatures value, valid values [&quot; + SelectFeatures.IWSS + &quot;, &quot; + SelectFeatures.CFS + &quot;, &quot; + SelectFeatures.FCBF + &quot;]&quot;);</span></span>
<span id="L103"><span class="lineNum"> 103</span> : }</span>
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 48 : hyperparameters.erase(&quot;select_features&quot;);</span></span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 60 : }</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 102 : if (hyperparameters.contains(&quot;block_update&quot;)) {</span></span>
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 12 : block_update = hyperparameters[&quot;block_update&quot;];</span></span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 12 : hyperparameters.erase(&quot;block_update&quot;);</span></span>
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 16 : hyperparameters.erase(&quot;select_features&quot;);</span></span>
<span id="L105"><span class="lineNum"> 105</span> <span class="tlaGNC"> 20 : }</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 34 : if (hyperparameters.contains(&quot;block_update&quot;)) {</span></span>
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 4 : block_update = hyperparameters[&quot;block_update&quot;];</span></span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 4 : hyperparameters.erase(&quot;block_update&quot;);</span></span>
<span id="L109"><span class="lineNum"> 109</span> : }</span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 102 : Classifier::setHyperparameters(hyperparameters);</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 216 : }</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 816 : std::tuple&lt;torch::Tensor&amp;, double, bool&gt; update_weights(torch::Tensor&amp; ytrain, torch::Tensor&amp; ypred, torch::Tensor&amp; weights)</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 34 : Classifier::setHyperparameters(hyperparameters);</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 72 : }</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 272 : std::tuple&lt;torch::Tensor&amp;, double, bool&gt; update_weights(torch::Tensor&amp; ytrain, torch::Tensor&amp; ypred, torch::Tensor&amp; weights)</span></span>
<span id="L113"><span class="lineNum"> 113</span> : {</span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 816 : bool terminate = false;</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 816 : double alpha_t = 0;</span></span>
<span id="L116"><span class="lineNum"> 116</span> <span class="tlaGNC"> 816 : auto mask_wrong = ypred != ytrain;</span></span>
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 816 : auto mask_right = ypred == ytrain;</span></span>
<span id="L118"><span class="lineNum"> 118</span> <span class="tlaGNC"> 816 : auto masked_weights = weights * mask_wrong.to(weights.dtype());</span></span>
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 816 : double epsilon_t = masked_weights.sum().item&lt;double&gt;();</span></span>
<span id="L120"><span class="lineNum"> 120</span> <span class="tlaGNC"> 816 : if (epsilon_t &gt; 0.5) {</span></span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 272 : bool terminate = false;</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 272 : double alpha_t = 0;</span></span>
<span id="L116"><span class="lineNum"> 116</span> <span class="tlaGNC"> 272 : auto mask_wrong = ypred != ytrain;</span></span>
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 272 : auto mask_right = ypred == ytrain;</span></span>
<span id="L118"><span class="lineNum"> 118</span> <span class="tlaGNC"> 272 : auto masked_weights = weights * mask_wrong.to(weights.dtype());</span></span>
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 272 : double epsilon_t = masked_weights.sum().item&lt;double&gt;();</span></span>
<span id="L120"><span class="lineNum"> 120</span> <span class="tlaGNC"> 272 : if (epsilon_t &gt; 0.5) {</span></span>
<span id="L121"><span class="lineNum"> 121</span> : // Inverse the weights policy (plot ln(wt))</span>
<span id="L122"><span class="lineNum"> 122</span> : // &quot;In each round of AdaBoost, there is a sanity check to ensure that the current base </span>
<span id="L123"><span class="lineNum"> 123</span> : // learner is better than random guess&quot; (Zhi-Hua Zhou, 2012)</span>
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 24 : terminate = true;</span></span>
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 8 : terminate = true;</span></span>
<span id="L125"><span class="lineNum"> 125</span> : } else {</span>
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 792 : double wt = (1 - epsilon_t) / epsilon_t;</span></span>
<span id="L127"><span class="lineNum"> 127</span> <span class="tlaGNC"> 792 : alpha_t = epsilon_t == 0 ? 1 : 0.5 * log(wt);</span></span>
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 264 : double wt = (1 - epsilon_t) / epsilon_t;</span></span>
<span id="L127"><span class="lineNum"> 127</span> <span class="tlaGNC"> 264 : alpha_t = epsilon_t == 0 ? 1 : 0.5 * log(wt);</span></span>
<span id="L128"><span class="lineNum"> 128</span> : // Step 3.2: Update weights for next classifier</span>
<span id="L129"><span class="lineNum"> 129</span> : // Step 3.2.1: Update weights of wrong samples</span>
<span id="L130"><span class="lineNum"> 130</span> <span class="tlaGNC"> 792 : weights += mask_wrong.to(weights.dtype()) * exp(alpha_t) * weights;</span></span>
<span id="L130"><span class="lineNum"> 130</span> <span class="tlaGNC"> 264 : weights += mask_wrong.to(weights.dtype()) * exp(alpha_t) * weights;</span></span>
<span id="L131"><span class="lineNum"> 131</span> : // Step 3.2.2: Update weights of right samples</span>
<span id="L132"><span class="lineNum"> 132</span> <span class="tlaGNC"> 792 : weights += mask_right.to(weights.dtype()) * exp(-alpha_t) * weights;</span></span>
<span id="L132"><span class="lineNum"> 132</span> <span class="tlaGNC"> 264 : weights += mask_right.to(weights.dtype()) * exp(-alpha_t) * weights;</span></span>
<span id="L133"><span class="lineNum"> 133</span> : // Step 3.3: Normalise the weights</span>
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 792 : double totalWeights = torch::sum(weights).item&lt;double&gt;();</span></span>
<span id="L135"><span class="lineNum"> 135</span> <span class="tlaGNC"> 792 : weights = weights / totalWeights;</span></span>
<span id="L134"><span class="lineNum"> 134</span> <span class="tlaGNC"> 264 : double totalWeights = torch::sum(weights).item&lt;double&gt;();</span></span>
<span id="L135"><span class="lineNum"> 135</span> <span class="tlaGNC"> 264 : weights = weights / totalWeights;</span></span>
<span id="L136"><span class="lineNum"> 136</span> : }</span>
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 1632 : return { weights, alpha_t, terminate };</span></span>
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 816 : }</span></span>
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 42 : std::tuple&lt;torch::Tensor&amp;, double, bool&gt; BoostAODE::update_weights_block(int k, torch::Tensor&amp; ytrain, torch::Tensor&amp; weights)</span></span>
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 544 : return { weights, alpha_t, terminate };</span></span>
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 272 : }</span></span>
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 14 : std::tuple&lt;torch::Tensor&amp;, double, bool&gt; BoostAODE::update_weights_block(int k, torch::Tensor&amp; ytrain, torch::Tensor&amp; weights)</span></span>
<span id="L140"><span class="lineNum"> 140</span> : {</span>
<span id="L141"><span class="lineNum"> 141</span> : /* Update Block algorithm</span>
<span id="L142"><span class="lineNum"> 142</span> : k = # of models in block</span>
@ -242,218 +242,218 @@
<span id="L180"><span class="lineNum"> 180</span> : //</span>
<span id="L181"><span class="lineNum"> 181</span> : // Make predict with only the last k models</span>
<span id="L182"><span class="lineNum"> 182</span> : //</span>
<span id="L183"><span class="lineNum"> 183</span> <span class="tlaGNC"> 42 : std::unique_ptr&lt;Classifier&gt; model;</span></span>
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 42 : std::vector&lt;std::unique_ptr&lt;Classifier&gt;&gt; models_bak;</span></span>
<span id="L183"><span class="lineNum"> 183</span> <span class="tlaGNC"> 14 : std::unique_ptr&lt;Classifier&gt; model;</span></span>
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 14 : std::vector&lt;std::unique_ptr&lt;Classifier&gt;&gt; models_bak;</span></span>
<span id="L185"><span class="lineNum"> 185</span> : // 1. n_models_bak &lt;- n_models 2. significances_bak &lt;- significances</span>
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 42 : auto significance_bak = significanceModels;</span></span>
<span id="L187"><span class="lineNum"> 187</span> <span class="tlaGNC"> 42 : auto n_models_bak = n_models;</span></span>
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 14 : auto significance_bak = significanceModels;</span></span>
<span id="L187"><span class="lineNum"> 187</span> <span class="tlaGNC"> 14 : auto n_models_bak = n_models;</span></span>
<span id="L188"><span class="lineNum"> 188</span> : // 3. significances = vector(k, 1)</span>
<span id="L189"><span class="lineNum"> 189</span> <span class="tlaGNC"> 42 : significanceModels = std::vector&lt;double&gt;(k, 1.0);</span></span>
<span id="L189"><span class="lineNum"> 189</span> <span class="tlaGNC"> 14 : significanceModels = std::vector&lt;double&gt;(k, 1.0);</span></span>
<span id="L190"><span class="lineNum"> 190</span> : // 4. Move first n classifiers to models_bak</span>
<span id="L191"><span class="lineNum"> 191</span> : // backup the first n_models - k models (if n_models == k, don't backup any)</span>
<span id="L192"><span class="lineNum"> 192</span> <span class="tlaGNC"> 222 : for (int i = 0; i &lt; n_models - k; ++i) {</span></span>
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 180 : model = std::move(models[0]);</span></span>
<span id="L194"><span class="lineNum"> 194</span> <span class="tlaGNC"> 180 : models.erase(models.begin());</span></span>
<span id="L195"><span class="lineNum"> 195</span> <span class="tlaGNC"> 180 : models_bak.push_back(std::move(model));</span></span>
<span id="L192"><span class="lineNum"> 192</span> <span class="tlaGNC"> 74 : for (int i = 0; i &lt; n_models - k; ++i) {</span></span>
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 60 : model = std::move(models[0]);</span></span>
<span id="L194"><span class="lineNum"> 194</span> <span class="tlaGNC"> 60 : models.erase(models.begin());</span></span>
<span id="L195"><span class="lineNum"> 195</span> <span class="tlaGNC"> 60 : models_bak.push_back(std::move(model));</span></span>
<span id="L196"><span class="lineNum"> 196</span> : }</span>
<span id="L197"><span class="lineNum"> 197</span> <span class="tlaGNC"> 42 : assert(models.size() == k);</span></span>
<span id="L197"><span class="lineNum"> 197</span> <span class="tlaGNC"> 14 : assert(models.size() == k);</span></span>
<span id="L198"><span class="lineNum"> 198</span> : // 5. n_models &lt;- k</span>
<span id="L199"><span class="lineNum"> 199</span> <span class="tlaGNC"> 42 : n_models = k;</span></span>
<span id="L199"><span class="lineNum"> 199</span> <span class="tlaGNC"> 14 : n_models = k;</span></span>
<span id="L200"><span class="lineNum"> 200</span> : // 6. Make prediction, compute alpha, update weights</span>
<span id="L201"><span class="lineNum"> 201</span> <span class="tlaGNC"> 42 : auto ypred = predict(X_train);</span></span>
<span id="L201"><span class="lineNum"> 201</span> <span class="tlaGNC"> 14 : auto ypred = predict(X_train);</span></span>
<span id="L202"><span class="lineNum"> 202</span> : //</span>
<span id="L203"><span class="lineNum"> 203</span> : // Update weights</span>
<span id="L204"><span class="lineNum"> 204</span> : //</span>
<span id="L205"><span class="lineNum"> 205</span> : double alpha_t;</span>
<span id="L206"><span class="lineNum"> 206</span> : bool terminate;</span>
<span id="L207"><span class="lineNum"> 207</span> <span class="tlaGNC"> 42 : std::tie(weights, alpha_t, terminate) = update_weights(y_train, ypred, weights);</span></span>
<span id="L207"><span class="lineNum"> 207</span> <span class="tlaGNC"> 14 : std::tie(weights, alpha_t, terminate) = update_weights(y_train, ypred, weights);</span></span>
<span id="L208"><span class="lineNum"> 208</span> : //</span>
<span id="L209"><span class="lineNum"> 209</span> : // Restore the models if needed</span>
<span id="L210"><span class="lineNum"> 210</span> : //</span>
<span id="L211"><span class="lineNum"> 211</span> : // 7. Insert classifiers in models_bak to be the first n models</span>
<span id="L212"><span class="lineNum"> 212</span> : // if n_models_bak == k, don't restore any, because none of them were moved</span>
<span id="L213"><span class="lineNum"> 213</span> <span class="tlaGNC"> 42 : if (k != n_models_bak) {</span></span>
<span id="L213"><span class="lineNum"> 213</span> <span class="tlaGNC"> 14 : if (k != n_models_bak) {</span></span>
<span id="L214"><span class="lineNum"> 214</span> : // Insert in the same order as they were extracted</span>
<span id="L215"><span class="lineNum"> 215</span> <span class="tlaGNC"> 36 : int bak_size = models_bak.size();</span></span>
<span id="L216"><span class="lineNum"> 216</span> <span class="tlaGNC"> 216 : for (int i = 0; i &lt; bak_size; ++i) {</span></span>
<span id="L217"><span class="lineNum"> 217</span> <span class="tlaGNC"> 180 : model = std::move(models_bak[bak_size - 1 - i]);</span></span>
<span id="L218"><span class="lineNum"> 218</span> <span class="tlaGNC"> 180 : models_bak.erase(models_bak.end() - 1);</span></span>
<span id="L219"><span class="lineNum"> 219</span> <span class="tlaGNC"> 180 : models.insert(models.begin(), std::move(model));</span></span>
<span id="L215"><span class="lineNum"> 215</span> <span class="tlaGNC"> 12 : int bak_size = models_bak.size();</span></span>
<span id="L216"><span class="lineNum"> 216</span> <span class="tlaGNC"> 72 : for (int i = 0; i &lt; bak_size; ++i) {</span></span>
<span id="L217"><span class="lineNum"> 217</span> <span class="tlaGNC"> 60 : model = std::move(models_bak[bak_size - 1 - i]);</span></span>
<span id="L218"><span class="lineNum"> 218</span> <span class="tlaGNC"> 60 : models_bak.erase(models_bak.end() - 1);</span></span>
<span id="L219"><span class="lineNum"> 219</span> <span class="tlaGNC"> 60 : models.insert(models.begin(), std::move(model));</span></span>
<span id="L220"><span class="lineNum"> 220</span> : }</span>
<span id="L221"><span class="lineNum"> 221</span> : }</span>
<span id="L222"><span class="lineNum"> 222</span> : // 8. significances &lt;- significances_bak</span>
<span id="L223"><span class="lineNum"> 223</span> <span class="tlaGNC"> 42 : significanceModels = significance_bak;</span></span>
<span id="L223"><span class="lineNum"> 223</span> <span class="tlaGNC"> 14 : significanceModels = significance_bak;</span></span>
<span id="L224"><span class="lineNum"> 224</span> : //</span>
<span id="L225"><span class="lineNum"> 225</span> : // Update the significance of the last k models</span>
<span id="L226"><span class="lineNum"> 226</span> : //</span>
<span id="L227"><span class="lineNum"> 227</span> : // 9. Update last k significances</span>
<span id="L228"><span class="lineNum"> 228</span> <span class="tlaGNC"> 156 : for (int i = 0; i &lt; k; ++i) {</span></span>
<span id="L229"><span class="lineNum"> 229</span> <span class="tlaGNC"> 114 : significanceModels[n_models_bak - k + i] = alpha_t;</span></span>
<span id="L228"><span class="lineNum"> 228</span> <span class="tlaGNC"> 52 : for (int i = 0; i &lt; k; ++i) {</span></span>
<span id="L229"><span class="lineNum"> 229</span> <span class="tlaGNC"> 38 : significanceModels[n_models_bak - k + i] = alpha_t;</span></span>
<span id="L230"><span class="lineNum"> 230</span> : }</span>
<span id="L231"><span class="lineNum"> 231</span> : // 10. n_models &lt;- n_models_bak</span>
<span id="L232"><span class="lineNum"> 232</span> <span class="tlaGNC"> 42 : n_models = n_models_bak;</span></span>
<span id="L233"><span class="lineNum"> 233</span> <span class="tlaGNC"> 84 : return { weights, alpha_t, terminate };</span></span>
<span id="L234"><span class="lineNum"> 234</span> <span class="tlaGNC"> 42 : }</span></span>
<span id="L235"><span class="lineNum"> 235</span> <span class="tlaGNC"> 48 : std::vector&lt;int&gt; BoostAODE::initializeModels()</span></span>
<span id="L232"><span class="lineNum"> 232</span> <span class="tlaGNC"> 14 : n_models = n_models_bak;</span></span>
<span id="L233"><span class="lineNum"> 233</span> <span class="tlaGNC"> 28 : return { weights, alpha_t, terminate };</span></span>
<span id="L234"><span class="lineNum"> 234</span> <span class="tlaGNC"> 14 : }</span></span>
<span id="L235"><span class="lineNum"> 235</span> <span class="tlaGNC"> 16 : std::vector&lt;int&gt; BoostAODE::initializeModels()</span></span>
<span id="L236"><span class="lineNum"> 236</span> : {</span>
<span id="L237"><span class="lineNum"> 237</span> <span class="tlaGNC"> 48 : std::vector&lt;int&gt; featuresUsed;</span></span>
<span id="L238"><span class="lineNum"> 238</span> <span class="tlaGNC"> 48 : torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);</span></span>
<span id="L239"><span class="lineNum"> 239</span> <span class="tlaGNC"> 48 : int maxFeatures = 0;</span></span>
<span id="L240"><span class="lineNum"> 240</span> <span class="tlaGNC"> 48 : if (select_features_algorithm == SelectFeatures.CFS) {</span></span>
<span id="L241"><span class="lineNum"> 241</span> <span class="tlaGNC"> 12 : featureSelector = new CFS(dataset, features, className, maxFeatures, states.at(className).size(), weights_);</span></span>
<span id="L242"><span class="lineNum"> 242</span> <span class="tlaGNC"> 36 : } else if (select_features_algorithm == SelectFeatures.IWSS) {</span></span>
<span id="L243"><span class="lineNum"> 243</span> <span class="tlaGNC"> 18 : if (threshold &lt; 0 || threshold &gt;0.5) {</span></span>
<span id="L244"><span class="lineNum"> 244</span> <span class="tlaGNC"> 12 : throw std::invalid_argument(&quot;Invalid threshold value for &quot; + SelectFeatures.IWSS + &quot; [0, 0.5]&quot;);</span></span>
<span id="L237"><span class="lineNum"> 237</span> <span class="tlaGNC"> 16 : std::vector&lt;int&gt; featuresUsed;</span></span>
<span id="L238"><span class="lineNum"> 238</span> <span class="tlaGNC"> 16 : torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);</span></span>
<span id="L239"><span class="lineNum"> 239</span> <span class="tlaGNC"> 16 : int maxFeatures = 0;</span></span>
<span id="L240"><span class="lineNum"> 240</span> <span class="tlaGNC"> 16 : if (select_features_algorithm == SelectFeatures.CFS) {</span></span>
<span id="L241"><span class="lineNum"> 241</span> <span class="tlaGNC"> 4 : featureSelector = new CFS(dataset, features, className, maxFeatures, states.at(className).size(), weights_);</span></span>
<span id="L242"><span class="lineNum"> 242</span> <span class="tlaGNC"> 12 : } else if (select_features_algorithm == SelectFeatures.IWSS) {</span></span>
<span id="L243"><span class="lineNum"> 243</span> <span class="tlaGNC"> 6 : if (threshold &lt; 0 || threshold &gt;0.5) {</span></span>
<span id="L244"><span class="lineNum"> 244</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;Invalid threshold value for &quot; + SelectFeatures.IWSS + &quot; [0, 0.5]&quot;);</span></span>
<span id="L245"><span class="lineNum"> 245</span> : }</span>
<span id="L246"><span class="lineNum"> 246</span> <span class="tlaGNC"> 6 : featureSelector = new IWSS(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);</span></span>
<span id="L247"><span class="lineNum"> 247</span> <span class="tlaGNC"> 18 : } else if (select_features_algorithm == SelectFeatures.FCBF) {</span></span>
<span id="L248"><span class="lineNum"> 248</span> <span class="tlaGNC"> 18 : if (threshold &lt; 1e-7 || threshold &gt; 1) {</span></span>
<span id="L249"><span class="lineNum"> 249</span> <span class="tlaGNC"> 12 : throw std::invalid_argument(&quot;Invalid threshold value for &quot; + SelectFeatures.FCBF + &quot; [1e-7, 1]&quot;);</span></span>
<span id="L246"><span class="lineNum"> 246</span> <span class="tlaGNC"> 2 : featureSelector = new IWSS(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);</span></span>
<span id="L247"><span class="lineNum"> 247</span> <span class="tlaGNC"> 6 : } else if (select_features_algorithm == SelectFeatures.FCBF) {</span></span>
<span id="L248"><span class="lineNum"> 248</span> <span class="tlaGNC"> 6 : if (threshold &lt; 1e-7 || threshold &gt; 1) {</span></span>
<span id="L249"><span class="lineNum"> 249</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;Invalid threshold value for &quot; + SelectFeatures.FCBF + &quot; [1e-7, 1]&quot;);</span></span>
<span id="L250"><span class="lineNum"> 250</span> : }</span>
<span id="L251"><span class="lineNum"> 251</span> <span class="tlaGNC"> 6 : featureSelector = new FCBF(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);</span></span>
<span id="L251"><span class="lineNum"> 251</span> <span class="tlaGNC"> 2 : featureSelector = new FCBF(dataset, features, className, maxFeatures, states.at(className).size(), weights_, threshold);</span></span>
<span id="L252"><span class="lineNum"> 252</span> : }</span>
<span id="L253"><span class="lineNum"> 253</span> <span class="tlaGNC"> 24 : featureSelector-&gt;fit();</span></span>
<span id="L254"><span class="lineNum"> 254</span> <span class="tlaGNC"> 24 : auto cfsFeatures = featureSelector-&gt;getFeatures();</span></span>
<span id="L255"><span class="lineNum"> 255</span> <span class="tlaGNC"> 24 : auto scores = featureSelector-&gt;getScores();</span></span>
<span id="L256"><span class="lineNum"> 256</span> <span class="tlaGNC"> 150 : for (const int&amp; feature : cfsFeatures) {</span></span>
<span id="L257"><span class="lineNum"> 257</span> <span class="tlaGNC"> 126 : featuresUsed.push_back(feature);</span></span>
<span id="L258"><span class="lineNum"> 258</span> <span class="tlaGNC"> 126 : std::unique_ptr&lt;Classifier&gt; model = std::make_unique&lt;SPODE&gt;(feature);</span></span>
<span id="L259"><span class="lineNum"> 259</span> <span class="tlaGNC"> 126 : model-&gt;fit(dataset, features, className, states, weights_);</span></span>
<span id="L260"><span class="lineNum"> 260</span> <span class="tlaGNC"> 126 : models.push_back(std::move(model));</span></span>
<span id="L261"><span class="lineNum"> 261</span> <span class="tlaGNC"> 126 : significanceModels.push_back(1.0); // They will be updated later in trainModel</span></span>
<span id="L262"><span class="lineNum"> 262</span> <span class="tlaGNC"> 126 : n_models++;</span></span>
<span id="L263"><span class="lineNum"> 263</span> <span class="tlaGNC"> 126 : }</span></span>
<span id="L264"><span class="lineNum"> 264</span> <span class="tlaGNC"> 24 : notes.push_back(&quot;Used features in initialization: &quot; + std::to_string(featuresUsed.size()) + &quot; of &quot; + std::to_string(features.size()) + &quot; with &quot; + select_features_algorithm);</span></span>
<span id="L265"><span class="lineNum"> 265</span> <span class="tlaGNC"> 24 : delete featureSelector;</span></span>
<span id="L266"><span class="lineNum"> 266</span> <span class="tlaGNC"> 48 : return featuresUsed;</span></span>
<span id="L267"><span class="lineNum"> 267</span> <span class="tlaGNC"> 72 : }</span></span>
<span id="L268"><span class="lineNum"> 268</span> <span class="tlaGNC"> 138 : void BoostAODE::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L253"><span class="lineNum"> 253</span> <span class="tlaGNC"> 8 : featureSelector-&gt;fit();</span></span>
<span id="L254"><span class="lineNum"> 254</span> <span class="tlaGNC"> 8 : auto cfsFeatures = featureSelector-&gt;getFeatures();</span></span>
<span id="L255"><span class="lineNum"> 255</span> <span class="tlaGNC"> 8 : auto scores = featureSelector-&gt;getScores();</span></span>
<span id="L256"><span class="lineNum"> 256</span> <span class="tlaGNC"> 50 : for (const int&amp; feature : cfsFeatures) {</span></span>
<span id="L257"><span class="lineNum"> 257</span> <span class="tlaGNC"> 42 : featuresUsed.push_back(feature);</span></span>
<span id="L258"><span class="lineNum"> 258</span> <span class="tlaGNC"> 42 : std::unique_ptr&lt;Classifier&gt; model = std::make_unique&lt;SPODE&gt;(feature);</span></span>
<span id="L259"><span class="lineNum"> 259</span> <span class="tlaGNC"> 42 : model-&gt;fit(dataset, features, className, states, weights_);</span></span>
<span id="L260"><span class="lineNum"> 260</span> <span class="tlaGNC"> 42 : models.push_back(std::move(model));</span></span>
<span id="L261"><span class="lineNum"> 261</span> <span class="tlaGNC"> 42 : significanceModels.push_back(1.0); // They will be updated later in trainModel</span></span>
<span id="L262"><span class="lineNum"> 262</span> <span class="tlaGNC"> 42 : n_models++;</span></span>
<span id="L263"><span class="lineNum"> 263</span> <span class="tlaGNC"> 42 : }</span></span>
<span id="L264"><span class="lineNum"> 264</span> <span class="tlaGNC"> 8 : notes.push_back(&quot;Used features in initialization: &quot; + std::to_string(featuresUsed.size()) + &quot; of &quot; + std::to_string(features.size()) + &quot; with &quot; + select_features_algorithm);</span></span>
<span id="L265"><span class="lineNum"> 265</span> <span class="tlaGNC"> 8 : delete featureSelector;</span></span>
<span id="L266"><span class="lineNum"> 266</span> <span class="tlaGNC"> 16 : return featuresUsed;</span></span>
<span id="L267"><span class="lineNum"> 267</span> <span class="tlaGNC"> 24 : }</span></span>
<span id="L268"><span class="lineNum"> 268</span> <span class="tlaGNC"> 46 : void BoostAODE::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L269"><span class="lineNum"> 269</span> : {</span>
<span id="L270"><span class="lineNum"> 270</span> : //</span>
<span id="L271"><span class="lineNum"> 271</span> : // Logging setup</span>
<span id="L272"><span class="lineNum"> 272</span> : //</span>
<span id="L273"><span class="lineNum"> 273</span> <span class="tlaGNC"> 138 : loguru::set_thread_name(&quot;BoostAODE&quot;);</span></span>
<span id="L274"><span class="lineNum"> 274</span> <span class="tlaGNC"> 138 : loguru::g_stderr_verbosity = loguru::Verbosity_OFF;</span></span>
<span id="L275"><span class="lineNum"> 275</span> <span class="tlaGNC"> 138 : loguru::add_file(&quot;boostAODE.log&quot;, loguru::Truncate, loguru::Verbosity_MAX);</span></span>
<span id="L273"><span class="lineNum"> 273</span> <span class="tlaGNC"> 46 : loguru::set_thread_name(&quot;BoostAODE&quot;);</span></span>
<span id="L274"><span class="lineNum"> 274</span> <span class="tlaGNC"> 46 : loguru::g_stderr_verbosity = loguru::Verbosity_OFF;</span></span>
<span id="L275"><span class="lineNum"> 275</span> <span class="tlaGNC"> 46 : loguru::add_file(&quot;boostAODE.log&quot;, loguru::Truncate, loguru::Verbosity_MAX);</span></span>
<span id="L276"><span class="lineNum"> 276</span> : </span>
<span id="L277"><span class="lineNum"> 277</span> : // Algorithm based on the adaboost algorithm for classification</span>
<span id="L278"><span class="lineNum"> 278</span> : // as explained in Ensemble methods (Zhi-Hua Zhou, 2012)</span>
<span id="L279"><span class="lineNum"> 279</span> <span class="tlaGNC"> 138 : fitted = true;</span></span>
<span id="L280"><span class="lineNum"> 280</span> <span class="tlaGNC"> 138 : double alpha_t = 0;</span></span>
<span id="L281"><span class="lineNum"> 281</span> <span class="tlaGNC"> 138 : torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);</span></span>
<span id="L282"><span class="lineNum"> 282</span> <span class="tlaGNC"> 138 : bool finished = false;</span></span>
<span id="L283"><span class="lineNum"> 283</span> <span class="tlaGNC"> 138 : std::vector&lt;int&gt; featuresUsed;</span></span>
<span id="L284"><span class="lineNum"> 284</span> <span class="tlaGNC"> 138 : if (selectFeatures) {</span></span>
<span id="L285"><span class="lineNum"> 285</span> <span class="tlaGNC"> 48 : featuresUsed = initializeModels();</span></span>
<span id="L286"><span class="lineNum"> 286</span> <span class="tlaGNC"> 24 : auto ypred = predict(X_train);</span></span>
<span id="L287"><span class="lineNum"> 287</span> <span class="tlaGNC"> 24 : std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);</span></span>
<span id="L279"><span class="lineNum"> 279</span> <span class="tlaGNC"> 46 : fitted = true;</span></span>
<span id="L280"><span class="lineNum"> 280</span> <span class="tlaGNC"> 46 : double alpha_t = 0;</span></span>
<span id="L281"><span class="lineNum"> 281</span> <span class="tlaGNC"> 46 : torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);</span></span>
<span id="L282"><span class="lineNum"> 282</span> <span class="tlaGNC"> 46 : bool finished = false;</span></span>
<span id="L283"><span class="lineNum"> 283</span> <span class="tlaGNC"> 46 : std::vector&lt;int&gt; featuresUsed;</span></span>
<span id="L284"><span class="lineNum"> 284</span> <span class="tlaGNC"> 46 : if (selectFeatures) {</span></span>
<span id="L285"><span class="lineNum"> 285</span> <span class="tlaGNC"> 16 : featuresUsed = initializeModels();</span></span>
<span id="L286"><span class="lineNum"> 286</span> <span class="tlaGNC"> 8 : auto ypred = predict(X_train);</span></span>
<span id="L287"><span class="lineNum"> 287</span> <span class="tlaGNC"> 8 : std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);</span></span>
<span id="L288"><span class="lineNum"> 288</span> : // Update significance of the models</span>
<span id="L289"><span class="lineNum"> 289</span> <span class="tlaGNC"> 150 : for (int i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L290"><span class="lineNum"> 290</span> <span class="tlaGNC"> 126 : significanceModels[i] = alpha_t;</span></span>
<span id="L289"><span class="lineNum"> 289</span> <span class="tlaGNC"> 50 : for (int i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L290"><span class="lineNum"> 290</span> <span class="tlaGNC"> 42 : significanceModels[i] = alpha_t;</span></span>
<span id="L291"><span class="lineNum"> 291</span> : }</span>
<span id="L292"><span class="lineNum"> 292</span> <span class="tlaGNC"> 24 : if (finished) {</span></span>
<span id="L292"><span class="lineNum"> 292</span> <span class="tlaGNC"> 8 : if (finished) {</span></span>
<span id="L293"><span class="lineNum"> 293</span> <span class="tlaUNC tlaBgUNC"> 0 : return;</span></span>
<span id="L294"><span class="lineNum"> 294</span> : }</span>
<span id="L295"><span class="lineNum"> 295</span> <span class="tlaGNC tlaBgGNC"> 24 : }</span></span>
<span id="L296"><span class="lineNum"> 296</span> <span class="tlaGNC"> 114 : int numItemsPack = 0; // The counter of the models inserted in the current pack</span></span>
<span id="L295"><span class="lineNum"> 295</span> <span class="tlaGNC tlaBgGNC"> 8 : }</span></span>
<span id="L296"><span class="lineNum"> 296</span> <span class="tlaGNC"> 38 : int numItemsPack = 0; // The counter of the models inserted in the current pack</span></span>
<span id="L297"><span class="lineNum"> 297</span> : // Variables to control the accuracy finish condition</span>
<span id="L298"><span class="lineNum"> 298</span> <span class="tlaGNC"> 114 : double priorAccuracy = 0.0;</span></span>
<span id="L299"><span class="lineNum"> 299</span> <span class="tlaGNC"> 114 : double improvement = 1.0;</span></span>
<span id="L300"><span class="lineNum"> 300</span> <span class="tlaGNC"> 114 : double convergence_threshold = 1e-4;</span></span>
<span id="L301"><span class="lineNum"> 301</span> <span class="tlaGNC"> 114 : int tolerance = 0; // number of times the accuracy is lower than the convergence_threshold</span></span>
<span id="L298"><span class="lineNum"> 298</span> <span class="tlaGNC"> 38 : double priorAccuracy = 0.0;</span></span>
<span id="L299"><span class="lineNum"> 299</span> <span class="tlaGNC"> 38 : double improvement = 1.0;</span></span>
<span id="L300"><span class="lineNum"> 300</span> <span class="tlaGNC"> 38 : double convergence_threshold = 1e-4;</span></span>
<span id="L301"><span class="lineNum"> 301</span> <span class="tlaGNC"> 38 : int tolerance = 0; // number of times the accuracy is lower than the convergence_threshold</span></span>
<span id="L302"><span class="lineNum"> 302</span> : // Step 0: Set the finish condition</span>
<span id="L303"><span class="lineNum"> 303</span> : // epsilon sub t &gt; 0.5 =&gt; inverse the weights policy</span>
<span id="L304"><span class="lineNum"> 304</span> : // validation error is not decreasing</span>
<span id="L305"><span class="lineNum"> 305</span> : // run out of features</span>
<span id="L306"><span class="lineNum"> 306</span> <span class="tlaGNC"> 114 : bool ascending = order_algorithm == Orders.ASC;</span></span>
<span id="L307"><span class="lineNum"> 307</span> <span class="tlaGNC"> 114 : std::mt19937 g{ 173 };</span></span>
<span id="L308"><span class="lineNum"> 308</span> <span class="tlaGNC"> 756 : while (!finished) {</span></span>
<span id="L306"><span class="lineNum"> 306</span> <span class="tlaGNC"> 38 : bool ascending = order_algorithm == Orders.ASC;</span></span>
<span id="L307"><span class="lineNum"> 307</span> <span class="tlaGNC"> 38 : std::mt19937 g{ 173 };</span></span>
<span id="L308"><span class="lineNum"> 308</span> <span class="tlaGNC"> 252 : while (!finished) {</span></span>
<span id="L309"><span class="lineNum"> 309</span> : // Step 1: Build ranking with mutual information</span>
<span id="L310"><span class="lineNum"> 310</span> <span class="tlaGNC"> 642 : auto featureSelection = metrics.SelectKBestWeighted(weights_, ascending, n); // Get all the features sorted</span></span>
<span id="L311"><span class="lineNum"> 311</span> <span class="tlaGNC"> 642 : if (order_algorithm == Orders.RAND) {</span></span>
<span id="L312"><span class="lineNum"> 312</span> <span class="tlaGNC"> 54 : std::shuffle(featureSelection.begin(), featureSelection.end(), g);</span></span>
<span id="L310"><span class="lineNum"> 310</span> <span class="tlaGNC"> 214 : auto featureSelection = metrics.SelectKBestWeighted(weights_, ascending, n); // Get all the features sorted</span></span>
<span id="L311"><span class="lineNum"> 311</span> <span class="tlaGNC"> 214 : if (order_algorithm == Orders.RAND) {</span></span>
<span id="L312"><span class="lineNum"> 312</span> <span class="tlaGNC"> 18 : std::shuffle(featureSelection.begin(), featureSelection.end(), g);</span></span>
<span id="L313"><span class="lineNum"> 313</span> : }</span>
<span id="L314"><span class="lineNum"> 314</span> : // Remove used features</span>
<span id="L315"><span class="lineNum"> 315</span> <span class="tlaGNC"> 1284 : featureSelection.erase(remove_if(begin(featureSelection), end(featureSelection), [&amp;](auto x)</span></span>
<span id="L316"><span class="lineNum"> 316</span> <span class="tlaGNC"> 58200 : { return std::find(begin(featuresUsed), end(featuresUsed), x) != end(featuresUsed);}),</span></span>
<span id="L317"><span class="lineNum"> 317</span> <span class="tlaGNC"> 642 : end(featureSelection)</span></span>
<span id="L315"><span class="lineNum"> 315</span> <span class="tlaGNC"> 428 : featureSelection.erase(remove_if(begin(featureSelection), end(featureSelection), [&amp;](auto x)</span></span>
<span id="L316"><span class="lineNum"> 316</span> <span class="tlaGNC"> 19400 : { return std::find(begin(featuresUsed), end(featuresUsed), x) != end(featuresUsed);}),</span></span>
<span id="L317"><span class="lineNum"> 317</span> <span class="tlaGNC"> 214 : end(featureSelection)</span></span>
<span id="L318"><span class="lineNum"> 318</span> : );</span>
<span id="L319"><span class="lineNum"> 319</span> <span class="tlaGNC"> 642 : int k = bisection ? pow(2, tolerance) : 1;</span></span>
<span id="L320"><span class="lineNum"> 320</span> <span class="tlaGNC"> 642 : int counter = 0; // The model counter of the current pack</span></span>
<span id="L321"><span class="lineNum"> 321</span> <span class="tlaGNC"> 642 : VLOG_SCOPE_F(1, &quot;counter=%d k=%d featureSelection.size: %zu&quot;, counter, k, featureSelection.size());</span></span>
<span id="L322"><span class="lineNum"> 322</span> <span class="tlaGNC"> 1506 : while (counter++ &lt; k &amp;&amp; featureSelection.size() &gt; 0) {</span></span>
<span id="L323"><span class="lineNum"> 323</span> <span class="tlaGNC"> 864 : auto feature = featureSelection[0];</span></span>
<span id="L324"><span class="lineNum"> 324</span> <span class="tlaGNC"> 864 : featureSelection.erase(featureSelection.begin());</span></span>
<span id="L325"><span class="lineNum"> 325</span> <span class="tlaGNC"> 864 : std::unique_ptr&lt;Classifier&gt; model;</span></span>
<span id="L326"><span class="lineNum"> 326</span> <span class="tlaGNC"> 864 : model = std::make_unique&lt;SPODE&gt;(feature);</span></span>
<span id="L327"><span class="lineNum"> 327</span> <span class="tlaGNC"> 864 : model-&gt;fit(dataset, features, className, states, weights_);</span></span>
<span id="L328"><span class="lineNum"> 328</span> <span class="tlaGNC"> 864 : alpha_t = 0.0;</span></span>
<span id="L329"><span class="lineNum"> 329</span> <span class="tlaGNC"> 864 : if (!block_update) {</span></span>
<span id="L330"><span class="lineNum"> 330</span> <span class="tlaGNC"> 750 : auto ypred = model-&gt;predict(X_train);</span></span>
<span id="L319"><span class="lineNum"> 319</span> <span class="tlaGNC"> 214 : int k = bisection ? pow(2, tolerance) : 1;</span></span>
<span id="L320"><span class="lineNum"> 320</span> <span class="tlaGNC"> 214 : int counter = 0; // The model counter of the current pack</span></span>
<span id="L321"><span class="lineNum"> 321</span> <span class="tlaGNC"> 214 : VLOG_SCOPE_F(1, &quot;counter=%d k=%d featureSelection.size: %zu&quot;, counter, k, featureSelection.size());</span></span>
<span id="L322"><span class="lineNum"> 322</span> <span class="tlaGNC"> 502 : while (counter++ &lt; k &amp;&amp; featureSelection.size() &gt; 0) {</span></span>
<span id="L323"><span class="lineNum"> 323</span> <span class="tlaGNC"> 288 : auto feature = featureSelection[0];</span></span>
<span id="L324"><span class="lineNum"> 324</span> <span class="tlaGNC"> 288 : featureSelection.erase(featureSelection.begin());</span></span>
<span id="L325"><span class="lineNum"> 325</span> <span class="tlaGNC"> 288 : std::unique_ptr&lt;Classifier&gt; model;</span></span>
<span id="L326"><span class="lineNum"> 326</span> <span class="tlaGNC"> 288 : model = std::make_unique&lt;SPODE&gt;(feature);</span></span>
<span id="L327"><span class="lineNum"> 327</span> <span class="tlaGNC"> 288 : model-&gt;fit(dataset, features, className, states, weights_);</span></span>
<span id="L328"><span class="lineNum"> 328</span> <span class="tlaGNC"> 288 : alpha_t = 0.0;</span></span>
<span id="L329"><span class="lineNum"> 329</span> <span class="tlaGNC"> 288 : if (!block_update) {</span></span>
<span id="L330"><span class="lineNum"> 330</span> <span class="tlaGNC"> 250 : auto ypred = model-&gt;predict(X_train);</span></span>
<span id="L331"><span class="lineNum"> 331</span> : // Step 3.1: Compute the classifier amout of say</span>
<span id="L332"><span class="lineNum"> 332</span> <span class="tlaGNC"> 750 : std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);</span></span>
<span id="L333"><span class="lineNum"> 333</span> <span class="tlaGNC"> 750 : }</span></span>
<span id="L332"><span class="lineNum"> 332</span> <span class="tlaGNC"> 250 : std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);</span></span>
<span id="L333"><span class="lineNum"> 333</span> <span class="tlaGNC"> 250 : }</span></span>
<span id="L334"><span class="lineNum"> 334</span> : // Step 3.4: Store classifier and its accuracy to weigh its future vote</span>
<span id="L335"><span class="lineNum"> 335</span> <span class="tlaGNC"> 864 : numItemsPack++;</span></span>
<span id="L336"><span class="lineNum"> 336</span> <span class="tlaGNC"> 864 : featuresUsed.push_back(feature);</span></span>
<span id="L337"><span class="lineNum"> 337</span> <span class="tlaGNC"> 864 : models.push_back(std::move(model));</span></span>
<span id="L338"><span class="lineNum"> 338</span> <span class="tlaGNC"> 864 : significanceModels.push_back(alpha_t);</span></span>
<span id="L339"><span class="lineNum"> 339</span> <span class="tlaGNC"> 864 : n_models++;</span></span>
<span id="L340"><span class="lineNum"> 340</span> <span class="tlaGNC"> 864 : VLOG_SCOPE_F(2, &quot;numItemsPack: %d n_models: %d featuresUsed: %zu&quot;, numItemsPack, n_models, featuresUsed.size());</span></span>
<span id="L341"><span class="lineNum"> 341</span> <span class="tlaGNC"> 864 : }</span></span>
<span id="L342"><span class="lineNum"> 342</span> <span class="tlaGNC"> 642 : if (block_update) {</span></span>
<span id="L343"><span class="lineNum"> 343</span> <span class="tlaGNC"> 42 : std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);</span></span>
<span id="L335"><span class="lineNum"> 335</span> <span class="tlaGNC"> 288 : numItemsPack++;</span></span>
<span id="L336"><span class="lineNum"> 336</span> <span class="tlaGNC"> 288 : featuresUsed.push_back(feature);</span></span>
<span id="L337"><span class="lineNum"> 337</span> <span class="tlaGNC"> 288 : models.push_back(std::move(model));</span></span>
<span id="L338"><span class="lineNum"> 338</span> <span class="tlaGNC"> 288 : significanceModels.push_back(alpha_t);</span></span>
<span id="L339"><span class="lineNum"> 339</span> <span class="tlaGNC"> 288 : n_models++;</span></span>
<span id="L340"><span class="lineNum"> 340</span> <span class="tlaGNC"> 288 : VLOG_SCOPE_F(2, &quot;numItemsPack: %d n_models: %d featuresUsed: %zu&quot;, numItemsPack, n_models, featuresUsed.size());</span></span>
<span id="L341"><span class="lineNum"> 341</span> <span class="tlaGNC"> 288 : }</span></span>
<span id="L342"><span class="lineNum"> 342</span> <span class="tlaGNC"> 214 : if (block_update) {</span></span>
<span id="L343"><span class="lineNum"> 343</span> <span class="tlaGNC"> 14 : std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);</span></span>
<span id="L344"><span class="lineNum"> 344</span> : }</span>
<span id="L345"><span class="lineNum"> 345</span> <span class="tlaGNC"> 642 : if (convergence &amp;&amp; !finished) {</span></span>
<span id="L346"><span class="lineNum"> 346</span> <span class="tlaGNC"> 444 : auto y_val_predict = predict(X_test);</span></span>
<span id="L347"><span class="lineNum"> 347</span> <span class="tlaGNC"> 444 : double accuracy = (y_val_predict == y_test).sum().item&lt;double&gt;() / (double)y_test.size(0);</span></span>
<span id="L348"><span class="lineNum"> 348</span> <span class="tlaGNC"> 444 : if (priorAccuracy == 0) {</span></span>
<span id="L349"><span class="lineNum"> 349</span> <span class="tlaGNC"> 90 : priorAccuracy = accuracy;</span></span>
<span id="L345"><span class="lineNum"> 345</span> <span class="tlaGNC"> 214 : if (convergence &amp;&amp; !finished) {</span></span>
<span id="L346"><span class="lineNum"> 346</span> <span class="tlaGNC"> 148 : auto y_val_predict = predict(X_test);</span></span>
<span id="L347"><span class="lineNum"> 347</span> <span class="tlaGNC"> 148 : double accuracy = (y_val_predict == y_test).sum().item&lt;double&gt;() / (double)y_test.size(0);</span></span>
<span id="L348"><span class="lineNum"> 348</span> <span class="tlaGNC"> 148 : if (priorAccuracy == 0) {</span></span>
<span id="L349"><span class="lineNum"> 349</span> <span class="tlaGNC"> 30 : priorAccuracy = accuracy;</span></span>
<span id="L350"><span class="lineNum"> 350</span> : } else {</span>
<span id="L351"><span class="lineNum"> 351</span> <span class="tlaGNC"> 354 : improvement = accuracy - priorAccuracy;</span></span>
<span id="L351"><span class="lineNum"> 351</span> <span class="tlaGNC"> 118 : improvement = accuracy - priorAccuracy;</span></span>
<span id="L352"><span class="lineNum"> 352</span> : }</span>
<span id="L353"><span class="lineNum"> 353</span> <span class="tlaGNC"> 444 : if (improvement &lt; convergence_threshold) {</span></span>
<span id="L354"><span class="lineNum"> 354</span> <span class="tlaGNC"> 264 : VLOG_SCOPE_F(3, &quot; (improvement&lt;threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f&quot;, tolerance, numItemsPack, improvement, priorAccuracy, accuracy);</span></span>
<span id="L355"><span class="lineNum"> 355</span> <span class="tlaGNC"> 264 : tolerance++;</span></span>
<span id="L356"><span class="lineNum"> 356</span> <span class="tlaGNC"> 264 : } else {</span></span>
<span id="L357"><span class="lineNum"> 357</span> <span class="tlaGNC"> 180 : VLOG_SCOPE_F(3, &quot;* (improvement&gt;=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f&quot;, tolerance, numItemsPack, improvement, priorAccuracy, accuracy);</span></span>
<span id="L358"><span class="lineNum"> 358</span> <span class="tlaGNC"> 180 : tolerance = 0; // Reset the counter if the model performs better</span></span>
<span id="L359"><span class="lineNum"> 359</span> <span class="tlaGNC"> 180 : numItemsPack = 0;</span></span>
<span id="L360"><span class="lineNum"> 360</span> <span class="tlaGNC"> 180 : }</span></span>
<span id="L361"><span class="lineNum"> 361</span> <span class="tlaGNC"> 444 : if (convergence_best) {</span></span>
<span id="L353"><span class="lineNum"> 353</span> <span class="tlaGNC"> 148 : if (improvement &lt; convergence_threshold) {</span></span>
<span id="L354"><span class="lineNum"> 354</span> <span class="tlaGNC"> 88 : VLOG_SCOPE_F(3, &quot; (improvement&lt;threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f&quot;, tolerance, numItemsPack, improvement, priorAccuracy, accuracy);</span></span>
<span id="L355"><span class="lineNum"> 355</span> <span class="tlaGNC"> 88 : tolerance++;</span></span>
<span id="L356"><span class="lineNum"> 356</span> <span class="tlaGNC"> 88 : } else {</span></span>
<span id="L357"><span class="lineNum"> 357</span> <span class="tlaGNC"> 60 : VLOG_SCOPE_F(3, &quot;* (improvement&gt;=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f&quot;, tolerance, numItemsPack, improvement, priorAccuracy, accuracy);</span></span>
<span id="L358"><span class="lineNum"> 358</span> <span class="tlaGNC"> 60 : tolerance = 0; // Reset the counter if the model performs better</span></span>
<span id="L359"><span class="lineNum"> 359</span> <span class="tlaGNC"> 60 : numItemsPack = 0;</span></span>
<span id="L360"><span class="lineNum"> 360</span> <span class="tlaGNC"> 60 : }</span></span>
<span id="L361"><span class="lineNum"> 361</span> <span class="tlaGNC"> 148 : if (convergence_best) {</span></span>
<span id="L362"><span class="lineNum"> 362</span> : // Keep the best accuracy until now as the prior accuracy</span>
<span id="L363"><span class="lineNum"> 363</span> <span class="tlaGNC"> 48 : priorAccuracy = std::max(accuracy, priorAccuracy);</span></span>
<span id="L363"><span class="lineNum"> 363</span> <span class="tlaGNC"> 16 : priorAccuracy = std::max(accuracy, priorAccuracy);</span></span>
<span id="L364"><span class="lineNum"> 364</span> : } else {</span>
<span id="L365"><span class="lineNum"> 365</span> : // Keep the last accuray obtained as the prior accuracy</span>
<span id="L366"><span class="lineNum"> 366</span> <span class="tlaGNC"> 396 : priorAccuracy = accuracy;</span></span>
<span id="L366"><span class="lineNum"> 366</span> <span class="tlaGNC"> 132 : priorAccuracy = accuracy;</span></span>
<span id="L367"><span class="lineNum"> 367</span> : }</span>
<span id="L368"><span class="lineNum"> 368</span> <span class="tlaGNC"> 444 : }</span></span>
<span id="L369"><span class="lineNum"> 369</span> <span class="tlaGNC"> 642 : VLOG_SCOPE_F(1, &quot;tolerance: %d featuresUsed.size: %zu features.size: %zu&quot;, tolerance, featuresUsed.size(), features.size());</span></span>
<span id="L370"><span class="lineNum"> 370</span> <span class="tlaGNC"> 642 : finished = finished || tolerance &gt; maxTolerance || featuresUsed.size() == features.size();</span></span>
<span id="L371"><span class="lineNum"> 371</span> <span class="tlaGNC"> 642 : }</span></span>
<span id="L372"><span class="lineNum"> 372</span> <span class="tlaGNC"> 114 : if (tolerance &gt; maxTolerance) {</span></span>
<span id="L373"><span class="lineNum"> 373</span> <span class="tlaGNC"> 12 : if (numItemsPack &lt; n_models) {</span></span>
<span id="L374"><span class="lineNum"> 374</span> <span class="tlaGNC"> 12 : notes.push_back(&quot;Convergence threshold reached &amp; &quot; + std::to_string(numItemsPack) + &quot; models eliminated&quot;);</span></span>
<span id="L375"><span class="lineNum"> 375</span> <span class="tlaGNC"> 12 : VLOG_SCOPE_F(4, &quot;Convergence threshold reached &amp; %d models eliminated of %d&quot;, numItemsPack, n_models);</span></span>
<span id="L376"><span class="lineNum"> 376</span> <span class="tlaGNC"> 156 : for (int i = 0; i &lt; numItemsPack; ++i) {</span></span>
<span id="L377"><span class="lineNum"> 377</span> <span class="tlaGNC"> 144 : significanceModels.pop_back();</span></span>
<span id="L378"><span class="lineNum"> 378</span> <span class="tlaGNC"> 144 : models.pop_back();</span></span>
<span id="L379"><span class="lineNum"> 379</span> <span class="tlaGNC"> 144 : n_models--;</span></span>
<span id="L368"><span class="lineNum"> 368</span> <span class="tlaGNC"> 148 : }</span></span>
<span id="L369"><span class="lineNum"> 369</span> <span class="tlaGNC"> 214 : VLOG_SCOPE_F(1, &quot;tolerance: %d featuresUsed.size: %zu features.size: %zu&quot;, tolerance, featuresUsed.size(), features.size());</span></span>
<span id="L370"><span class="lineNum"> 370</span> <span class="tlaGNC"> 214 : finished = finished || tolerance &gt; maxTolerance || featuresUsed.size() == features.size();</span></span>
<span id="L371"><span class="lineNum"> 371</span> <span class="tlaGNC"> 214 : }</span></span>
<span id="L372"><span class="lineNum"> 372</span> <span class="tlaGNC"> 38 : if (tolerance &gt; maxTolerance) {</span></span>
<span id="L373"><span class="lineNum"> 373</span> <span class="tlaGNC"> 4 : if (numItemsPack &lt; n_models) {</span></span>
<span id="L374"><span class="lineNum"> 374</span> <span class="tlaGNC"> 4 : notes.push_back(&quot;Convergence threshold reached &amp; &quot; + std::to_string(numItemsPack) + &quot; models eliminated&quot;);</span></span>
<span id="L375"><span class="lineNum"> 375</span> <span class="tlaGNC"> 4 : VLOG_SCOPE_F(4, &quot;Convergence threshold reached &amp; %d models eliminated of %d&quot;, numItemsPack, n_models);</span></span>
<span id="L376"><span class="lineNum"> 376</span> <span class="tlaGNC"> 52 : for (int i = 0; i &lt; numItemsPack; ++i) {</span></span>
<span id="L377"><span class="lineNum"> 377</span> <span class="tlaGNC"> 48 : significanceModels.pop_back();</span></span>
<span id="L378"><span class="lineNum"> 378</span> <span class="tlaGNC"> 48 : models.pop_back();</span></span>
<span id="L379"><span class="lineNum"> 379</span> <span class="tlaGNC"> 48 : n_models--;</span></span>
<span id="L380"><span class="lineNum"> 380</span> : }</span>
<span id="L381"><span class="lineNum"> 381</span> <span class="tlaGNC"> 12 : } else {</span></span>
<span id="L381"><span class="lineNum"> 381</span> <span class="tlaGNC"> 4 : } else {</span></span>
<span id="L382"><span class="lineNum"> 382</span> <span class="tlaUNC tlaBgUNC"> 0 : notes.push_back(&quot;Convergence threshold reached &amp; 0 models eliminated&quot;);</span></span>
<span id="L383"><span class="lineNum"> 383</span> <span class="tlaUNC"> 0 : VLOG_SCOPE_F(4, &quot;Convergence threshold reached &amp; 0 models eliminated n_models=%d numItemsPack=%d&quot;, n_models, numItemsPack);</span></span>
<span id="L384"><span class="lineNum"> 384</span> <span class="tlaUNC"> 0 : }</span></span>
<span id="L385"><span class="lineNum"> 385</span> : }</span>
<span id="L386"><span class="lineNum"> 386</span> <span class="tlaGNC tlaBgGNC"> 114 : if (featuresUsed.size() != features.size()) {</span></span>
<span id="L387"><span class="lineNum"> 387</span> <span class="tlaGNC"> 6 : notes.push_back(&quot;Used features in train: &quot; + std::to_string(featuresUsed.size()) + &quot; of &quot; + std::to_string(features.size()));</span></span>
<span id="L388"><span class="lineNum"> 388</span> <span class="tlaGNC"> 6 : status = WARNING;</span></span>
<span id="L386"><span class="lineNum"> 386</span> <span class="tlaGNC tlaBgGNC"> 38 : if (featuresUsed.size() != features.size()) {</span></span>
<span id="L387"><span class="lineNum"> 387</span> <span class="tlaGNC"> 2 : notes.push_back(&quot;Used features in train: &quot; + std::to_string(featuresUsed.size()) + &quot; of &quot; + std::to_string(features.size()));</span></span>
<span id="L388"><span class="lineNum"> 388</span> <span class="tlaGNC"> 2 : status = WARNING;</span></span>
<span id="L389"><span class="lineNum"> 389</span> : }</span>
<span id="L390"><span class="lineNum"> 390</span> <span class="tlaGNC"> 114 : notes.push_back(&quot;Number of models: &quot; + std::to_string(n_models));</span></span>
<span id="L391"><span class="lineNum"> 391</span> <span class="tlaGNC"> 162 : }</span></span>
<span id="L392"><span class="lineNum"> 392</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; BoostAODE::graph(const std::string&amp; title) const</span></span>
<span id="L390"><span class="lineNum"> 390</span> <span class="tlaGNC"> 38 : notes.push_back(&quot;Number of models: &quot; + std::to_string(n_models));</span></span>
<span id="L391"><span class="lineNum"> 391</span> <span class="tlaGNC"> 54 : }</span></span>
<span id="L392"><span class="lineNum"> 392</span> <span class="tlaGNC"> 2 : std::vector&lt;std::string&gt; BoostAODE::graph(const std::string&amp; title) const</span></span>
<span id="L393"><span class="lineNum"> 393</span> : {</span>
<span id="L394"><span class="lineNum"> 394</span> <span class="tlaGNC"> 6 : return Ensemble::graph(title);</span></span>
<span id="L394"><span class="lineNum"> 394</span> <span class="tlaGNC"> 2 : return Ensemble::graph(title);</span></span>
<span id="L395"><span class="lineNum"> 395</span> : }</span>
<span id="L396"><span class="lineNum"> 396</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="BoostAODE.h.gcov.html#L25">bayesnet::BoostAODE::~BoostAODE()</a></td>
<td class="coverFnHi">132</td>
<td class="coverFnHi">44</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="BoostAODE.h.gcov.html#L25">bayesnet::BoostAODE::~BoostAODE()</a></td>
<td class="coverFnHi">132</td>
<td class="coverFnHi">44</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -86,7 +86,7 @@
<span id="L24"><span class="lineNum"> 24</span> : class BoostAODE : public Ensemble {</span>
<span id="L25"><span class="lineNum"> 25</span> : public:</span>
<span id="L26"><span class="lineNum"> 26</span> : explicit BoostAODE(bool predict_voting = false);</span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC tlaBgGNC"> 132 : virtual ~BoostAODE() = default;</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC tlaBgGNC"> 44 : virtual ~BoostAODE() = default;</span></span>
<span id="L28"><span class="lineNum"> 28</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; title = &quot;BoostAODE&quot;) const override;</span>
<span id="L29"><span class="lineNum"> 29</span> : void setHyperparameters(const nlohmann::json&amp; hyperparameters_) override;</span>
<span id="L30"><span class="lineNum"> 30</span> : protected:</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,175 +65,175 @@
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L212">bayesnet::Ensemble::getNumberOfStates() const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L178">bayesnet::Ensemble::show[abi:cxx11]() const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L187">bayesnet::Ensemble::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">18</td>
<td class="coverFnHi">6</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L204">bayesnet::Ensemble::getNumberOfEdges() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L196">bayesnet::Ensemble::getNumberOfNodes() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L14">bayesnet::Ensemble::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L131">bayesnet::Ensemble::predict_average_voting(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">42</td>
<td class="coverFnHi">14</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L102">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">54</td>
<td class="coverFnHi">18</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L167">bayesnet::Ensemble::score(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">60</td>
<td class="coverFnHi">20</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L22">bayesnet::Ensemble::compute_arg_max(std::vector&lt;std::vector&lt;double, std::allocator&lt;double&gt; &gt;, std::allocator&lt;std::vector&lt;double, std::allocator&lt;double&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">66</td>
<td class="coverFnHi">22</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L72">bayesnet::Ensemble::predict(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">84</td>
<td class="coverFnHi">28</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L156">bayesnet::Ensemble::score(at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">120</td>
<td class="coverFnHi">40</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L58">bayesnet::Ensemble::predict_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">132</td>
<td class="coverFnHi">44</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L138">bayesnet::Ensemble::predict_average_voting(at::Tensor&amp;)</a></td>
<td class="coverFnHi">240</td>
<td class="coverFnHi">80</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L36">bayesnet::Ensemble::voting(at::Tensor&amp;)</a></td>
<td class="coverFnHi">240</td>
<td class="coverFnHi">80</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L109">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)::{lambda()#1}::operator()() const</a></td>
<td class="coverFnHi">366</td>
<td class="coverFnHi">122</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L82">bayesnet::Ensemble::predict_average_proba(at::Tensor&amp;)</a></td>
<td class="coverFnHi">444</td>
<td class="coverFnHi">148</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L9">bayesnet::Ensemble::Ensemble(bool)</a></td>
<td class="coverFnHi">468</td>
<td class="coverFnHi">156</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L31">bayesnet::Ensemble::compute_arg_max(at::Tensor&amp;)</a></td>
<td class="coverFnHi">636</td>
<td class="coverFnHi">212</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L77">bayesnet::Ensemble::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">654</td>
<td class="coverFnHi">218</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L65">bayesnet::Ensemble::predict_proba(at::Tensor&amp;)</a></td>
<td class="coverFnHi">678</td>
<td class="coverFnHi">226</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L145">bayesnet::Ensemble::predict_average_voting(at::Tensor&amp;)::{lambda()#1}::operator()() const</a></td>
<td class="coverFnHi">1608</td>
<td class="coverFnHi">536</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L89">bayesnet::Ensemble::predict_average_proba(at::Tensor&amp;)::{lambda()#1}::operator()() const</a></td>
<td class="coverFnHi">2202</td>
<td class="coverFnHi">734</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L127">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)::{lambda(double)#1}::operator()(double) const</a></td>
<td class="coverFnHi">49320</td>
<td class="coverFnHi">16440</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L117">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)::{lambda()#1}::operator()() const::{lambda(double, double)#1}::operator()(double, double) const</a></td>
<td class="coverFnHi">389880</td>
<td class="coverFnHi">129960</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,175 +65,175 @@
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L9">bayesnet::Ensemble::Ensemble(bool)</a></td>
<td class="coverFnHi">468</td>
<td class="coverFnHi">156</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L31">bayesnet::Ensemble::compute_arg_max(at::Tensor&amp;)</a></td>
<td class="coverFnHi">636</td>
<td class="coverFnHi">212</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L22">bayesnet::Ensemble::compute_arg_max(std::vector&lt;std::vector&lt;double, std::allocator&lt;double&gt; &gt;, std::allocator&lt;std::vector&lt;double, std::allocator&lt;double&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">66</td>
<td class="coverFnHi">22</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L204">bayesnet::Ensemble::getNumberOfEdges() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L196">bayesnet::Ensemble::getNumberOfNodes() const</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L212">bayesnet::Ensemble::getNumberOfStates() const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L187">bayesnet::Ensemble::graph(std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;) const</a></td>
<td class="coverFnHi">18</td>
<td class="coverFnHi">6</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L77">bayesnet::Ensemble::predict(at::Tensor&amp;)</a></td>
<td class="coverFnHi">654</td>
<td class="coverFnHi">218</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L72">bayesnet::Ensemble::predict(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">84</td>
<td class="coverFnHi">28</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L82">bayesnet::Ensemble::predict_average_proba(at::Tensor&amp;)</a></td>
<td class="coverFnHi">444</td>
<td class="coverFnHi">148</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L89">bayesnet::Ensemble::predict_average_proba(at::Tensor&amp;)::{lambda()#1}::operator()() const</a></td>
<td class="coverFnHi">2202</td>
<td class="coverFnHi">734</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L102">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">54</td>
<td class="coverFnHi">18</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L109">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)::{lambda()#1}::operator()() const</a></td>
<td class="coverFnHi">366</td>
<td class="coverFnHi">122</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L117">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)::{lambda()#1}::operator()() const::{lambda(double, double)#1}::operator()(double, double) const</a></td>
<td class="coverFnHi">389880</td>
<td class="coverFnHi">129960</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L127">bayesnet::Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)::{lambda(double)#1}::operator()(double) const</a></td>
<td class="coverFnHi">49320</td>
<td class="coverFnHi">16440</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L138">bayesnet::Ensemble::predict_average_voting(at::Tensor&amp;)</a></td>
<td class="coverFnHi">240</td>
<td class="coverFnHi">80</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L145">bayesnet::Ensemble::predict_average_voting(at::Tensor&amp;)::{lambda()#1}::operator()() const</a></td>
<td class="coverFnHi">1608</td>
<td class="coverFnHi">536</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L131">bayesnet::Ensemble::predict_average_voting(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">42</td>
<td class="coverFnHi">14</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L65">bayesnet::Ensemble::predict_proba(at::Tensor&amp;)</a></td>
<td class="coverFnHi">678</td>
<td class="coverFnHi">226</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L58">bayesnet::Ensemble::predict_proba(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;)</a></td>
<td class="coverFnHi">132</td>
<td class="coverFnHi">44</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L156">bayesnet::Ensemble::score(at::Tensor&amp;, at::Tensor&amp;)</a></td>
<td class="coverFnHi">120</td>
<td class="coverFnHi">40</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L167">bayesnet::Ensemble::score(std::vector&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt;, std::allocator&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt; &gt;&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)</a></td>
<td class="coverFnHi">60</td>
<td class="coverFnHi">20</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L178">bayesnet::Ensemble::show[abi:cxx11]() const</a></td>
<td class="coverFnHi">6</td>
<td class="coverFnHi">2</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L14">bayesnet::Ensemble::trainModel(at::Tensor const&amp;)</a></td>
<td class="coverFnHi">36</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.cc.gcov.html#L36">bayesnet::Ensemble::voting(at::Tensor&amp;)</a></td>
<td class="coverFnHi">240</td>
<td class="coverFnHi">80</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -70,216 +70,216 @@
<span id="L8"><span class="lineNum"> 8</span> : </span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> : </span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 468 : Ensemble::Ensemble(bool predict_voting) : Classifier(Network()), n_models(0), predict_voting(predict_voting)</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 156 : Ensemble::Ensemble(bool predict_voting) : Classifier(Network()), n_models(0), predict_voting(predict_voting)</span></span>
<span id="L12"><span class="lineNum"> 12</span> : {</span>
<span id="L13"><span class="lineNum"> 13</span> : </span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 468 : };</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 156 : };</span></span>
<span id="L15"><span class="lineNum"> 15</span> : const std::string ENSEMBLE_NOT_FITTED = &quot;Ensemble has not been fitted&quot;;</span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 36 : void Ensemble::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 12 : void Ensemble::trainModel(const torch::Tensor&amp; weights)</span></span>
<span id="L17"><span class="lineNum"> 17</span> : {</span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 36 : n_models = models.size();</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 282 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 12 : n_models = models.size();</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 94 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L20"><span class="lineNum"> 20</span> : // fit with std::vectors</span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 246 : models[i]-&gt;fit(dataset, features, className, states);</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 82 : models[i]-&gt;fit(dataset, features, className, states);</span></span>
<span id="L22"><span class="lineNum"> 22</span> : }</span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 36 : }</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 66 : std::vector&lt;int&gt; Ensemble::compute_arg_max(std::vector&lt;std::vector&lt;double&gt;&gt;&amp; X)</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 12 : }</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 22 : std::vector&lt;int&gt; Ensemble::compute_arg_max(std::vector&lt;std::vector&lt;double&gt;&gt;&amp; X)</span></span>
<span id="L25"><span class="lineNum"> 25</span> : {</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 66 : std::vector&lt;int&gt; y_pred;</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 14730 : for (auto i = 0; i &lt; X.size(); ++i) {</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 14664 : auto max = std::max_element(X[i].begin(), X[i].end());</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 29328 : y_pred.push_back(std::distance(X[i].begin(), max));</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 22 : std::vector&lt;int&gt; y_pred;</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 4910 : for (auto i = 0; i &lt; X.size(); ++i) {</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 4888 : auto max = std::max_element(X[i].begin(), X[i].end());</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 9776 : y_pred.push_back(std::distance(X[i].begin(), max));</span></span>
<span id="L30"><span class="lineNum"> 30</span> : }</span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 66 : return y_pred;</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 22 : return y_pred;</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaUNC tlaBgUNC"> 0 : }</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC tlaBgGNC"> 636 : torch::Tensor Ensemble::compute_arg_max(torch::Tensor&amp; X)</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC tlaBgGNC"> 212 : torch::Tensor Ensemble::compute_arg_max(torch::Tensor&amp; X)</span></span>
<span id="L34"><span class="lineNum"> 34</span> : {</span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 636 : auto y_pred = torch::argmax(X, 1);</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 636 : return y_pred;</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 212 : auto y_pred = torch::argmax(X, 1);</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 212 : return y_pred;</span></span>
<span id="L37"><span class="lineNum"> 37</span> : }</span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 240 : torch::Tensor Ensemble::voting(torch::Tensor&amp; votes)</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC"> 80 : torch::Tensor Ensemble::voting(torch::Tensor&amp; votes)</span></span>
<span id="L39"><span class="lineNum"> 39</span> : {</span>
<span id="L40"><span class="lineNum"> 40</span> : // Convert m x n_models tensor to a m x n_class_states with voting probabilities</span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 240 : auto y_pred_ = votes.accessor&lt;int, 2&gt;();</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 240 : std::vector&lt;int&gt; y_pred_final;</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 240 : int numClasses = states.at(className).size();</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 80 : auto y_pred_ = votes.accessor&lt;int, 2&gt;();</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 80 : std::vector&lt;int&gt; y_pred_final;</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 80 : int numClasses = states.at(className).size();</span></span>
<span id="L44"><span class="lineNum"> 44</span> : // votes is m x n_models with the prediction of every model for each sample</span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 240 : auto result = torch::zeros({ votes.size(0), numClasses }, torch::kFloat32);</span></span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 240 : auto sum = std::reduce(significanceModels.begin(), significanceModels.end());</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 61836 : for (int i = 0; i &lt; votes.size(0); ++i) {</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 80 : auto result = torch::zeros({ votes.size(0), numClasses }, torch::kFloat32);</span></span>
<span id="L46"><span class="lineNum"> 46</span> <span class="tlaGNC"> 80 : auto sum = std::reduce(significanceModels.begin(), significanceModels.end());</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 20612 : for (int i = 0; i &lt; votes.size(0); ++i) {</span></span>
<span id="L48"><span class="lineNum"> 48</span> : // n_votes store in each index (value of class) the significance added by each model</span>
<span id="L49"><span class="lineNum"> 49</span> : // i.e. n_votes[0] contains how much value has the value 0 of class. That value is generated by the models predictions</span>
<span id="L50"><span class="lineNum"> 50</span> <span class="tlaGNC"> 61596 : std::vector&lt;double&gt; n_votes(numClasses, 0.0);</span></span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 515400 : for (int j = 0; j &lt; n_models; ++j) {</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 453804 : n_votes[y_pred_[i][j]] += significanceModels.at(j);</span></span>
<span id="L50"><span class="lineNum"> 50</span> <span class="tlaGNC"> 20532 : std::vector&lt;double&gt; n_votes(numClasses, 0.0);</span></span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 171800 : for (int j = 0; j &lt; n_models; ++j) {</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 151268 : n_votes[y_pred_[i][j]] += significanceModels.at(j);</span></span>
<span id="L53"><span class="lineNum"> 53</span> : }</span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 61596 : result[i] = torch::tensor(n_votes);</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 61596 : }</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 20532 : result[i] = torch::tensor(n_votes);</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 20532 : }</span></span>
<span id="L56"><span class="lineNum"> 56</span> : // To only do one division and gain precision</span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 240 : result /= sum;</span></span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 480 : return result;</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 240 : }</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 132 : std::vector&lt;std::vector&lt;double&gt;&gt; Ensemble::predict_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 80 : result /= sum;</span></span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 160 : return result;</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 80 : }</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 44 : std::vector&lt;std::vector&lt;double&gt;&gt; Ensemble::predict_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L61"><span class="lineNum"> 61</span> : {</span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 132 : if (!fitted) {</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 36 : throw std::logic_error(ENSEMBLE_NOT_FITTED);</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 44 : if (!fitted) {</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 12 : throw std::logic_error(ENSEMBLE_NOT_FITTED);</span></span>
<span id="L64"><span class="lineNum"> 64</span> : }</span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 96 : return predict_voting ? predict_average_voting(X) : predict_average_proba(X);</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 32 : return predict_voting ? predict_average_voting(X) : predict_average_proba(X);</span></span>
<span id="L66"><span class="lineNum"> 66</span> : }</span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 678 : torch::Tensor Ensemble::predict_proba(torch::Tensor&amp; X)</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 226 : torch::Tensor Ensemble::predict_proba(torch::Tensor&amp; X)</span></span>
<span id="L68"><span class="lineNum"> 68</span> : {</span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 678 : if (!fitted) {</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 36 : throw std::logic_error(ENSEMBLE_NOT_FITTED);</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 226 : if (!fitted) {</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 12 : throw std::logic_error(ENSEMBLE_NOT_FITTED);</span></span>
<span id="L71"><span class="lineNum"> 71</span> : }</span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 642 : return predict_voting ? predict_average_voting(X) : predict_average_proba(X);</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 214 : return predict_voting ? predict_average_voting(X) : predict_average_proba(X);</span></span>
<span id="L73"><span class="lineNum"> 73</span> : }</span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 84 : std::vector&lt;int&gt; Ensemble::predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L74"><span class="lineNum"> 74</span> <span class="tlaGNC"> 28 : std::vector&lt;int&gt; Ensemble::predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L75"><span class="lineNum"> 75</span> : {</span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 84 : auto res = predict_proba(X);</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 120 : return compute_arg_max(res);</span></span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 60 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 654 : torch::Tensor Ensemble::predict(torch::Tensor&amp; X)</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 28 : auto res = predict_proba(X);</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 40 : return compute_arg_max(res);</span></span>
<span id="L78"><span class="lineNum"> 78</span> <span class="tlaGNC"> 20 : }</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 218 : torch::Tensor Ensemble::predict(torch::Tensor&amp; X)</span></span>
<span id="L80"><span class="lineNum"> 80</span> : {</span>
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 654 : auto res = predict_proba(X);</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 1260 : return compute_arg_max(res);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 630 : }</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 444 : torch::Tensor Ensemble::predict_average_proba(torch::Tensor&amp; X)</span></span>
<span id="L81"><span class="lineNum"> 81</span> <span class="tlaGNC"> 218 : auto res = predict_proba(X);</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 420 : return compute_arg_max(res);</span></span>
<span id="L83"><span class="lineNum"> 83</span> <span class="tlaGNC"> 210 : }</span></span>
<span id="L84"><span class="lineNum"> 84</span> <span class="tlaGNC"> 148 : torch::Tensor Ensemble::predict_average_proba(torch::Tensor&amp; X)</span></span>
<span id="L85"><span class="lineNum"> 85</span> : {</span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 444 : auto n_states = models[0]-&gt;getClassNumStates();</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 444 : torch::Tensor y_pred = torch::zeros({ X.size(1), n_states }, torch::kFloat32);</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 444 : auto threads{ std::vector&lt;std::thread&gt;() };</span></span>
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 444 : std::mutex mtx;</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 2646 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 2202 : threads.push_back(std::thread([&amp;, i]() {</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 2202 : auto ypredict = models[i]-&gt;predict_proba(X);</span></span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 2202 : std::lock_guard&lt;std::mutex&gt; lock(mtx);</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 2202 : y_pred += ypredict * significanceModels[i];</span></span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 2202 : }));</span></span>
<span id="L86"><span class="lineNum"> 86</span> <span class="tlaGNC"> 148 : auto n_states = models[0]-&gt;getClassNumStates();</span></span>
<span id="L87"><span class="lineNum"> 87</span> <span class="tlaGNC"> 148 : torch::Tensor y_pred = torch::zeros({ X.size(1), n_states }, torch::kFloat32);</span></span>
<span id="L88"><span class="lineNum"> 88</span> <span class="tlaGNC"> 148 : auto threads{ std::vector&lt;std::thread&gt;() };</span></span>
<span id="L89"><span class="lineNum"> 89</span> <span class="tlaGNC"> 148 : std::mutex mtx;</span></span>
<span id="L90"><span class="lineNum"> 90</span> <span class="tlaGNC"> 882 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L91"><span class="lineNum"> 91</span> <span class="tlaGNC"> 734 : threads.push_back(std::thread([&amp;, i]() {</span></span>
<span id="L92"><span class="lineNum"> 92</span> <span class="tlaGNC"> 734 : auto ypredict = models[i]-&gt;predict_proba(X);</span></span>
<span id="L93"><span class="lineNum"> 93</span> <span class="tlaGNC"> 734 : std::lock_guard&lt;std::mutex&gt; lock(mtx);</span></span>
<span id="L94"><span class="lineNum"> 94</span> <span class="tlaGNC"> 734 : y_pred += ypredict * significanceModels[i];</span></span>
<span id="L95"><span class="lineNum"> 95</span> <span class="tlaGNC"> 734 : }));</span></span>
<span id="L96"><span class="lineNum"> 96</span> : }</span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 2646 : for (auto&amp; thread : threads) {</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 2202 : thread.join();</span></span>
<span id="L97"><span class="lineNum"> 97</span> <span class="tlaGNC"> 882 : for (auto&amp; thread : threads) {</span></span>
<span id="L98"><span class="lineNum"> 98</span> <span class="tlaGNC"> 734 : thread.join();</span></span>
<span id="L99"><span class="lineNum"> 99</span> : }</span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 444 : auto sum = std::reduce(significanceModels.begin(), significanceModels.end());</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 444 : y_pred /= sum;</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 888 : return y_pred;</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 444 : }</span></span>
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 54 : std::vector&lt;std::vector&lt;double&gt;&gt; Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L100"><span class="lineNum"> 100</span> <span class="tlaGNC"> 148 : auto sum = std::reduce(significanceModels.begin(), significanceModels.end());</span></span>
<span id="L101"><span class="lineNum"> 101</span> <span class="tlaGNC"> 148 : y_pred /= sum;</span></span>
<span id="L102"><span class="lineNum"> 102</span> <span class="tlaGNC"> 296 : return y_pred;</span></span>
<span id="L103"><span class="lineNum"> 103</span> <span class="tlaGNC"> 148 : }</span></span>
<span id="L104"><span class="lineNum"> 104</span> <span class="tlaGNC"> 18 : std::vector&lt;std::vector&lt;double&gt;&gt; Ensemble::predict_average_proba(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L105"><span class="lineNum"> 105</span> : {</span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 54 : auto n_states = models[0]-&gt;getClassNumStates();</span></span>
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 54 : std::vector&lt;std::vector&lt;double&gt;&gt; y_pred(X[0].size(), std::vector&lt;double&gt;(n_states, 0.0));</span></span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 54 : auto threads{ std::vector&lt;std::thread&gt;() };</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 54 : std::mutex mtx;</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 420 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 366 : threads.push_back(std::thread([&amp;, i]() {</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 366 : auto ypredict = models[i]-&gt;predict_proba(X);</span></span>
<span id="L113"><span class="lineNum"> 113</span> <span class="tlaGNC"> 366 : assert(ypredict.size() == y_pred.size());</span></span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 366 : assert(ypredict[0].size() == y_pred[0].size());</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 366 : std::lock_guard&lt;std::mutex&gt; lock(mtx);</span></span>
<span id="L106"><span class="lineNum"> 106</span> <span class="tlaGNC"> 18 : auto n_states = models[0]-&gt;getClassNumStates();</span></span>
<span id="L107"><span class="lineNum"> 107</span> <span class="tlaGNC"> 18 : std::vector&lt;std::vector&lt;double&gt;&gt; y_pred(X[0].size(), std::vector&lt;double&gt;(n_states, 0.0));</span></span>
<span id="L108"><span class="lineNum"> 108</span> <span class="tlaGNC"> 18 : auto threads{ std::vector&lt;std::thread&gt;() };</span></span>
<span id="L109"><span class="lineNum"> 109</span> <span class="tlaGNC"> 18 : std::mutex mtx;</span></span>
<span id="L110"><span class="lineNum"> 110</span> <span class="tlaGNC"> 140 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L111"><span class="lineNum"> 111</span> <span class="tlaGNC"> 122 : threads.push_back(std::thread([&amp;, i]() {</span></span>
<span id="L112"><span class="lineNum"> 112</span> <span class="tlaGNC"> 122 : auto ypredict = models[i]-&gt;predict_proba(X);</span></span>
<span id="L113"><span class="lineNum"> 113</span> <span class="tlaGNC"> 122 : assert(ypredict.size() == y_pred.size());</span></span>
<span id="L114"><span class="lineNum"> 114</span> <span class="tlaGNC"> 122 : assert(ypredict[0].size() == y_pred[0].size());</span></span>
<span id="L115"><span class="lineNum"> 115</span> <span class="tlaGNC"> 122 : std::lock_guard&lt;std::mutex&gt; lock(mtx);</span></span>
<span id="L116"><span class="lineNum"> 116</span> : // Multiply each prediction by the significance of the model and then add it to the final prediction</span>
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 72546 : for (auto j = 0; j &lt; ypredict.size(); ++j) {</span></span>
<span id="L118"><span class="lineNum"> 118</span> <span class="tlaGNC"> 72180 : std::transform(y_pred[j].begin(), y_pred[j].end(), ypredict[j].begin(), y_pred[j].begin(),</span></span>
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 462060 : [significanceModels = significanceModels[i]](double x, double y) { return x + y * significanceModels; });</span></span>
<span id="L117"><span class="lineNum"> 117</span> <span class="tlaGNC"> 24182 : for (auto j = 0; j &lt; ypredict.size(); ++j) {</span></span>
<span id="L118"><span class="lineNum"> 118</span> <span class="tlaGNC"> 24060 : std::transform(y_pred[j].begin(), y_pred[j].end(), ypredict[j].begin(), y_pred[j].begin(),</span></span>
<span id="L119"><span class="lineNum"> 119</span> <span class="tlaGNC"> 154020 : [significanceModels = significanceModels[i]](double x, double y) { return x + y * significanceModels; });</span></span>
<span id="L120"><span class="lineNum"> 120</span> : }</span>
<span id="L121"><span class="lineNum"> 121</span> <span class="tlaGNC"> 366 : }));</span></span>
<span id="L121"><span class="lineNum"> 121</span> <span class="tlaGNC"> 122 : }));</span></span>
<span id="L122"><span class="lineNum"> 122</span> : }</span>
<span id="L123"><span class="lineNum"> 123</span> <span class="tlaGNC"> 420 : for (auto&amp; thread : threads) {</span></span>
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 366 : thread.join();</span></span>
<span id="L123"><span class="lineNum"> 123</span> <span class="tlaGNC"> 140 : for (auto&amp; thread : threads) {</span></span>
<span id="L124"><span class="lineNum"> 124</span> <span class="tlaGNC"> 122 : thread.join();</span></span>
<span id="L125"><span class="lineNum"> 125</span> : }</span>
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 54 : auto sum = std::reduce(significanceModels.begin(), significanceModels.end());</span></span>
<span id="L126"><span class="lineNum"> 126</span> <span class="tlaGNC"> 18 : auto sum = std::reduce(significanceModels.begin(), significanceModels.end());</span></span>
<span id="L127"><span class="lineNum"> 127</span> : //Divide each element of the prediction by the sum of the significances</span>
<span id="L128"><span class="lineNum"> 128</span> <span class="tlaGNC"> 10074 : for (auto j = 0; j &lt; y_pred.size(); ++j) {</span></span>
<span id="L129"><span class="lineNum"> 129</span> <span class="tlaGNC"> 59340 : std::transform(y_pred[j].begin(), y_pred[j].end(), y_pred[j].begin(), [sum](double x) { return x / sum; });</span></span>
<span id="L128"><span class="lineNum"> 128</span> <span class="tlaGNC"> 3358 : for (auto j = 0; j &lt; y_pred.size(); ++j) {</span></span>
<span id="L129"><span class="lineNum"> 129</span> <span class="tlaGNC"> 19780 : std::transform(y_pred[j].begin(), y_pred[j].end(), y_pred[j].begin(), [sum](double x) { return x / sum; });</span></span>
<span id="L130"><span class="lineNum"> 130</span> : }</span>
<span id="L131"><span class="lineNum"> 131</span> <span class="tlaGNC"> 108 : return y_pred;</span></span>
<span id="L132"><span class="lineNum"> 132</span> <span class="tlaGNC"> 54 : }</span></span>
<span id="L133"><span class="lineNum"> 133</span> <span class="tlaGNC"> 42 : std::vector&lt;std::vector&lt;double&gt;&gt; Ensemble::predict_average_voting(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L131"><span class="lineNum"> 131</span> <span class="tlaGNC"> 36 : return y_pred;</span></span>
<span id="L132"><span class="lineNum"> 132</span> <span class="tlaGNC"> 18 : }</span></span>
<span id="L133"><span class="lineNum"> 133</span> <span class="tlaGNC"> 14 : std::vector&lt;std::vector&lt;double&gt;&gt; Ensemble::predict_average_voting(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X)</span></span>
<span id="L134"><span class="lineNum"> 134</span> : {</span>
<span id="L135"><span class="lineNum"> 135</span> <span class="tlaGNC"> 42 : torch::Tensor Xt = bayesnet::vectorToTensor(X, false);</span></span>
<span id="L136"><span class="lineNum"> 136</span> <span class="tlaGNC"> 42 : auto y_pred = predict_average_voting(Xt);</span></span>
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 42 : std::vector&lt;std::vector&lt;double&gt;&gt; result = tensorToVectorDouble(y_pred);</span></span>
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 84 : return result;</span></span>
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 42 : }</span></span>
<span id="L140"><span class="lineNum"> 140</span> <span class="tlaGNC"> 240 : torch::Tensor Ensemble::predict_average_voting(torch::Tensor&amp; X)</span></span>
<span id="L135"><span class="lineNum"> 135</span> <span class="tlaGNC"> 14 : torch::Tensor Xt = bayesnet::vectorToTensor(X, false);</span></span>
<span id="L136"><span class="lineNum"> 136</span> <span class="tlaGNC"> 14 : auto y_pred = predict_average_voting(Xt);</span></span>
<span id="L137"><span class="lineNum"> 137</span> <span class="tlaGNC"> 14 : std::vector&lt;std::vector&lt;double&gt;&gt; result = tensorToVectorDouble(y_pred);</span></span>
<span id="L138"><span class="lineNum"> 138</span> <span class="tlaGNC"> 28 : return result;</span></span>
<span id="L139"><span class="lineNum"> 139</span> <span class="tlaGNC"> 14 : }</span></span>
<span id="L140"><span class="lineNum"> 140</span> <span class="tlaGNC"> 80 : torch::Tensor Ensemble::predict_average_voting(torch::Tensor&amp; X)</span></span>
<span id="L141"><span class="lineNum"> 141</span> : {</span>
<span id="L142"><span class="lineNum"> 142</span> : // Build a m x n_models tensor with the predictions of each model</span>
<span id="L143"><span class="lineNum"> 143</span> <span class="tlaGNC"> 240 : torch::Tensor y_pred = torch::zeros({ X.size(1), n_models }, torch::kInt32);</span></span>
<span id="L144"><span class="lineNum"> 144</span> <span class="tlaGNC"> 240 : auto threads{ std::vector&lt;std::thread&gt;() };</span></span>
<span id="L145"><span class="lineNum"> 145</span> <span class="tlaGNC"> 240 : std::mutex mtx;</span></span>
<span id="L146"><span class="lineNum"> 146</span> <span class="tlaGNC"> 1848 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L147"><span class="lineNum"> 147</span> <span class="tlaGNC"> 1608 : threads.push_back(std::thread([&amp;, i]() {</span></span>
<span id="L148"><span class="lineNum"> 148</span> <span class="tlaGNC"> 1608 : auto ypredict = models[i]-&gt;predict(X);</span></span>
<span id="L149"><span class="lineNum"> 149</span> <span class="tlaGNC"> 1608 : std::lock_guard&lt;std::mutex&gt; lock(mtx);</span></span>
<span id="L150"><span class="lineNum"> 150</span> <span class="tlaGNC"> 4824 : y_pred.index_put_({ &quot;...&quot;, i }, ypredict);</span></span>
<span id="L151"><span class="lineNum"> 151</span> <span class="tlaGNC"> 3216 : }));</span></span>
<span id="L143"><span class="lineNum"> 143</span> <span class="tlaGNC"> 80 : torch::Tensor y_pred = torch::zeros({ X.size(1), n_models }, torch::kInt32);</span></span>
<span id="L144"><span class="lineNum"> 144</span> <span class="tlaGNC"> 80 : auto threads{ std::vector&lt;std::thread&gt;() };</span></span>
<span id="L145"><span class="lineNum"> 145</span> <span class="tlaGNC"> 80 : std::mutex mtx;</span></span>
<span id="L146"><span class="lineNum"> 146</span> <span class="tlaGNC"> 616 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L147"><span class="lineNum"> 147</span> <span class="tlaGNC"> 536 : threads.push_back(std::thread([&amp;, i]() {</span></span>
<span id="L148"><span class="lineNum"> 148</span> <span class="tlaGNC"> 536 : auto ypredict = models[i]-&gt;predict(X);</span></span>
<span id="L149"><span class="lineNum"> 149</span> <span class="tlaGNC"> 536 : std::lock_guard&lt;std::mutex&gt; lock(mtx);</span></span>
<span id="L150"><span class="lineNum"> 150</span> <span class="tlaGNC"> 1608 : y_pred.index_put_({ &quot;...&quot;, i }, ypredict);</span></span>
<span id="L151"><span class="lineNum"> 151</span> <span class="tlaGNC"> 1072 : }));</span></span>
<span id="L152"><span class="lineNum"> 152</span> : }</span>
<span id="L153"><span class="lineNum"> 153</span> <span class="tlaGNC"> 1848 : for (auto&amp; thread : threads) {</span></span>
<span id="L154"><span class="lineNum"> 154</span> <span class="tlaGNC"> 1608 : thread.join();</span></span>
<span id="L153"><span class="lineNum"> 153</span> <span class="tlaGNC"> 616 : for (auto&amp; thread : threads) {</span></span>
<span id="L154"><span class="lineNum"> 154</span> <span class="tlaGNC"> 536 : thread.join();</span></span>
<span id="L155"><span class="lineNum"> 155</span> : }</span>
<span id="L156"><span class="lineNum"> 156</span> <span class="tlaGNC"> 480 : return voting(y_pred);</span></span>
<span id="L157"><span class="lineNum"> 157</span> <span class="tlaGNC"> 240 : }</span></span>
<span id="L158"><span class="lineNum"> 158</span> <span class="tlaGNC"> 120 : float Ensemble::score(torch::Tensor&amp; X, torch::Tensor&amp; y)</span></span>
<span id="L156"><span class="lineNum"> 156</span> <span class="tlaGNC"> 160 : return voting(y_pred);</span></span>
<span id="L157"><span class="lineNum"> 157</span> <span class="tlaGNC"> 80 : }</span></span>
<span id="L158"><span class="lineNum"> 158</span> <span class="tlaGNC"> 40 : float Ensemble::score(torch::Tensor&amp; X, torch::Tensor&amp; y)</span></span>
<span id="L159"><span class="lineNum"> 159</span> : {</span>
<span id="L160"><span class="lineNum"> 160</span> <span class="tlaGNC"> 120 : auto y_pred = predict(X);</span></span>
<span id="L161"><span class="lineNum"> 161</span> <span class="tlaGNC"> 108 : int correct = 0;</span></span>
<span id="L162"><span class="lineNum"> 162</span> <span class="tlaGNC"> 33876 : for (int i = 0; i &lt; y_pred.size(0); ++i) {</span></span>
<span id="L163"><span class="lineNum"> 163</span> <span class="tlaGNC"> 33768 : if (y_pred[i].item&lt;int&gt;() == y[i].item&lt;int&gt;()) {</span></span>
<span id="L164"><span class="lineNum"> 164</span> <span class="tlaGNC"> 29502 : correct++;</span></span>
<span id="L160"><span class="lineNum"> 160</span> <span class="tlaGNC"> 40 : auto y_pred = predict(X);</span></span>
<span id="L161"><span class="lineNum"> 161</span> <span class="tlaGNC"> 36 : int correct = 0;</span></span>
<span id="L162"><span class="lineNum"> 162</span> <span class="tlaGNC"> 11292 : for (int i = 0; i &lt; y_pred.size(0); ++i) {</span></span>
<span id="L163"><span class="lineNum"> 163</span> <span class="tlaGNC"> 11256 : if (y_pred[i].item&lt;int&gt;() == y[i].item&lt;int&gt;()) {</span></span>
<span id="L164"><span class="lineNum"> 164</span> <span class="tlaGNC"> 9834 : correct++;</span></span>
<span id="L165"><span class="lineNum"> 165</span> : }</span>
<span id="L166"><span class="lineNum"> 166</span> : }</span>
<span id="L167"><span class="lineNum"> 167</span> <span class="tlaGNC"> 216 : return (double)correct / y_pred.size(0);</span></span>
<span id="L168"><span class="lineNum"> 168</span> <span class="tlaGNC"> 108 : }</span></span>
<span id="L169"><span class="lineNum"> 169</span> <span class="tlaGNC"> 60 : float Ensemble::score(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y)</span></span>
<span id="L167"><span class="lineNum"> 167</span> <span class="tlaGNC"> 72 : return (double)correct / y_pred.size(0);</span></span>
<span id="L168"><span class="lineNum"> 168</span> <span class="tlaGNC"> 36 : }</span></span>
<span id="L169"><span class="lineNum"> 169</span> <span class="tlaGNC"> 20 : float Ensemble::score(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X, std::vector&lt;int&gt;&amp; y)</span></span>
<span id="L170"><span class="lineNum"> 170</span> : {</span>
<span id="L171"><span class="lineNum"> 171</span> <span class="tlaGNC"> 60 : auto y_pred = predict(X);</span></span>
<span id="L172"><span class="lineNum"> 172</span> <span class="tlaGNC"> 48 : int correct = 0;</span></span>
<span id="L173"><span class="lineNum"> 173</span> <span class="tlaGNC"> 12876 : for (int i = 0; i &lt; y_pred.size(); ++i) {</span></span>
<span id="L174"><span class="lineNum"> 174</span> <span class="tlaGNC"> 12828 : if (y_pred[i] == y[i]) {</span></span>
<span id="L175"><span class="lineNum"> 175</span> <span class="tlaGNC"> 10722 : correct++;</span></span>
<span id="L171"><span class="lineNum"> 171</span> <span class="tlaGNC"> 20 : auto y_pred = predict(X);</span></span>
<span id="L172"><span class="lineNum"> 172</span> <span class="tlaGNC"> 16 : int correct = 0;</span></span>
<span id="L173"><span class="lineNum"> 173</span> <span class="tlaGNC"> 4292 : for (int i = 0; i &lt; y_pred.size(); ++i) {</span></span>
<span id="L174"><span class="lineNum"> 174</span> <span class="tlaGNC"> 4276 : if (y_pred[i] == y[i]) {</span></span>
<span id="L175"><span class="lineNum"> 175</span> <span class="tlaGNC"> 3574 : correct++;</span></span>
<span id="L176"><span class="lineNum"> 176</span> : }</span>
<span id="L177"><span class="lineNum"> 177</span> : }</span>
<span id="L178"><span class="lineNum"> 178</span> <span class="tlaGNC"> 96 : return (double)correct / y_pred.size();</span></span>
<span id="L179"><span class="lineNum"> 179</span> <span class="tlaGNC"> 48 : }</span></span>
<span id="L180"><span class="lineNum"> 180</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; Ensemble::show() const</span></span>
<span id="L178"><span class="lineNum"> 178</span> <span class="tlaGNC"> 32 : return (double)correct / y_pred.size();</span></span>
<span id="L179"><span class="lineNum"> 179</span> <span class="tlaGNC"> 16 : }</span></span>
<span id="L180"><span class="lineNum"> 180</span> <span class="tlaGNC"> 2 : std::vector&lt;std::string&gt; Ensemble::show() const</span></span>
<span id="L181"><span class="lineNum"> 181</span> : {</span>
<span id="L182"><span class="lineNum"> 182</span> <span class="tlaGNC"> 6 : auto result = std::vector&lt;std::string&gt;();</span></span>
<span id="L183"><span class="lineNum"> 183</span> <span class="tlaGNC"> 30 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 24 : auto res = models[i]-&gt;show();</span></span>
<span id="L185"><span class="lineNum"> 185</span> <span class="tlaGNC"> 24 : result.insert(result.end(), res.begin(), res.end());</span></span>
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 24 : }</span></span>
<span id="L187"><span class="lineNum"> 187</span> <span class="tlaGNC"> 6 : return result;</span></span>
<span id="L182"><span class="lineNum"> 182</span> <span class="tlaGNC"> 2 : auto result = std::vector&lt;std::string&gt;();</span></span>
<span id="L183"><span class="lineNum"> 183</span> <span class="tlaGNC"> 10 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L184"><span class="lineNum"> 184</span> <span class="tlaGNC"> 8 : auto res = models[i]-&gt;show();</span></span>
<span id="L185"><span class="lineNum"> 185</span> <span class="tlaGNC"> 8 : result.insert(result.end(), res.begin(), res.end());</span></span>
<span id="L186"><span class="lineNum"> 186</span> <span class="tlaGNC"> 8 : }</span></span>
<span id="L187"><span class="lineNum"> 187</span> <span class="tlaGNC"> 2 : return result;</span></span>
<span id="L188"><span class="lineNum"> 188</span> <span class="tlaUNC tlaBgUNC"> 0 : }</span></span>
<span id="L189"><span class="lineNum"> 189</span> <span class="tlaGNC tlaBgGNC"> 18 : std::vector&lt;std::string&gt; Ensemble::graph(const std::string&amp; title) const</span></span>
<span id="L189"><span class="lineNum"> 189</span> <span class="tlaGNC tlaBgGNC"> 6 : std::vector&lt;std::string&gt; Ensemble::graph(const std::string&amp; title) const</span></span>
<span id="L190"><span class="lineNum"> 190</span> : {</span>
<span id="L191"><span class="lineNum"> 191</span> <span class="tlaGNC"> 18 : auto result = std::vector&lt;std::string&gt;();</span></span>
<span id="L192"><span class="lineNum"> 192</span> <span class="tlaGNC"> 120 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 102 : auto res = models[i]-&gt;graph(title + &quot;_&quot; + std::to_string(i));</span></span>
<span id="L194"><span class="lineNum"> 194</span> <span class="tlaGNC"> 102 : result.insert(result.end(), res.begin(), res.end());</span></span>
<span id="L195"><span class="lineNum"> 195</span> <span class="tlaGNC"> 102 : }</span></span>
<span id="L196"><span class="lineNum"> 196</span> <span class="tlaGNC"> 18 : return result;</span></span>
<span id="L191"><span class="lineNum"> 191</span> <span class="tlaGNC"> 6 : auto result = std::vector&lt;std::string&gt;();</span></span>
<span id="L192"><span class="lineNum"> 192</span> <span class="tlaGNC"> 40 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L193"><span class="lineNum"> 193</span> <span class="tlaGNC"> 34 : auto res = models[i]-&gt;graph(title + &quot;_&quot; + std::to_string(i));</span></span>
<span id="L194"><span class="lineNum"> 194</span> <span class="tlaGNC"> 34 : result.insert(result.end(), res.begin(), res.end());</span></span>
<span id="L195"><span class="lineNum"> 195</span> <span class="tlaGNC"> 34 : }</span></span>
<span id="L196"><span class="lineNum"> 196</span> <span class="tlaGNC"> 6 : return result;</span></span>
<span id="L197"><span class="lineNum"> 197</span> <span class="tlaUNC tlaBgUNC"> 0 : }</span></span>
<span id="L198"><span class="lineNum"> 198</span> <span class="tlaGNC tlaBgGNC"> 36 : int Ensemble::getNumberOfNodes() const</span></span>
<span id="L198"><span class="lineNum"> 198</span> <span class="tlaGNC tlaBgGNC"> 12 : int Ensemble::getNumberOfNodes() const</span></span>
<span id="L199"><span class="lineNum"> 199</span> : {</span>
<span id="L200"><span class="lineNum"> 200</span> <span class="tlaGNC"> 36 : int nodes = 0;</span></span>
<span id="L201"><span class="lineNum"> 201</span> <span class="tlaGNC"> 300 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L202"><span class="lineNum"> 202</span> <span class="tlaGNC"> 264 : nodes += models[i]-&gt;getNumberOfNodes();</span></span>
<span id="L200"><span class="lineNum"> 200</span> <span class="tlaGNC"> 12 : int nodes = 0;</span></span>
<span id="L201"><span class="lineNum"> 201</span> <span class="tlaGNC"> 100 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L202"><span class="lineNum"> 202</span> <span class="tlaGNC"> 88 : nodes += models[i]-&gt;getNumberOfNodes();</span></span>
<span id="L203"><span class="lineNum"> 203</span> : }</span>
<span id="L204"><span class="lineNum"> 204</span> <span class="tlaGNC"> 36 : return nodes;</span></span>
<span id="L204"><span class="lineNum"> 204</span> <span class="tlaGNC"> 12 : return nodes;</span></span>
<span id="L205"><span class="lineNum"> 205</span> : }</span>
<span id="L206"><span class="lineNum"> 206</span> <span class="tlaGNC"> 36 : int Ensemble::getNumberOfEdges() const</span></span>
<span id="L206"><span class="lineNum"> 206</span> <span class="tlaGNC"> 12 : int Ensemble::getNumberOfEdges() const</span></span>
<span id="L207"><span class="lineNum"> 207</span> : {</span>
<span id="L208"><span class="lineNum"> 208</span> <span class="tlaGNC"> 36 : int edges = 0;</span></span>
<span id="L209"><span class="lineNum"> 209</span> <span class="tlaGNC"> 300 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L210"><span class="lineNum"> 210</span> <span class="tlaGNC"> 264 : edges += models[i]-&gt;getNumberOfEdges();</span></span>
<span id="L208"><span class="lineNum"> 208</span> <span class="tlaGNC"> 12 : int edges = 0;</span></span>
<span id="L209"><span class="lineNum"> 209</span> <span class="tlaGNC"> 100 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L210"><span class="lineNum"> 210</span> <span class="tlaGNC"> 88 : edges += models[i]-&gt;getNumberOfEdges();</span></span>
<span id="L211"><span class="lineNum"> 211</span> : }</span>
<span id="L212"><span class="lineNum"> 212</span> <span class="tlaGNC"> 36 : return edges;</span></span>
<span id="L212"><span class="lineNum"> 212</span> <span class="tlaGNC"> 12 : return edges;</span></span>
<span id="L213"><span class="lineNum"> 213</span> : }</span>
<span id="L214"><span class="lineNum"> 214</span> <span class="tlaGNC"> 6 : int Ensemble::getNumberOfStates() const</span></span>
<span id="L214"><span class="lineNum"> 214</span> <span class="tlaGNC"> 2 : int Ensemble::getNumberOfStates() const</span></span>
<span id="L215"><span class="lineNum"> 215</span> : {</span>
<span id="L216"><span class="lineNum"> 216</span> <span class="tlaGNC"> 6 : int nstates = 0;</span></span>
<span id="L217"><span class="lineNum"> 217</span> <span class="tlaGNC"> 30 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L218"><span class="lineNum"> 218</span> <span class="tlaGNC"> 24 : nstates += models[i]-&gt;getNumberOfStates();</span></span>
<span id="L216"><span class="lineNum"> 216</span> <span class="tlaGNC"> 2 : int nstates = 0;</span></span>
<span id="L217"><span class="lineNum"> 217</span> <span class="tlaGNC"> 10 : for (auto i = 0; i &lt; n_models; ++i) {</span></span>
<span id="L218"><span class="lineNum"> 218</span> <span class="tlaGNC"> 8 : nstates += models[i]-&gt;getNumberOfStates();</span></span>
<span id="L219"><span class="lineNum"> 219</span> : }</span>
<span id="L220"><span class="lineNum"> 220</span> <span class="tlaGNC"> 6 : return nstates;</span></span>
<span id="L220"><span class="lineNum"> 220</span> <span class="tlaGNC"> 2 : return nstates;</span></span>
<span id="L221"><span class="lineNum"> 221</span> : }</span>
<span id="L222"><span class="lineNum"> 222</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,21 +65,21 @@
<tr>
<td class="coverFn"><a href="Ensemble.h.gcov.html#L32">bayesnet::Ensemble::dump_cpt[abi:cxx11]() const</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.h.gcov.html#L28">bayesnet::Ensemble::topological_order[abi:cxx11]()</a></td>
<td class="coverFnHi">18</td>
<td class="coverFnHi">6</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.h.gcov.html#L16">bayesnet::Ensemble::~Ensemble()</a></td>
<td class="coverFnHi">168</td>
<td class="coverFnHi">56</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,21 +65,21 @@
<tr>
<td class="coverFn"><a href="Ensemble.h.gcov.html#L32">bayesnet::Ensemble::dump_cpt[abi:cxx11]() const</a></td>
<td class="coverFnHi">12</td>
<td class="coverFnHi">4</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.h.gcov.html#L28">bayesnet::Ensemble::topological_order[abi:cxx11]()</a></td>
<td class="coverFnHi">18</td>
<td class="coverFnHi">6</td>
</tr>
<tr>
<td class="coverFn"><a href="Ensemble.h.gcov.html#L16">bayesnet::Ensemble::~Ensemble()</a></td>
<td class="coverFnHi">168</td>
<td class="coverFnHi">56</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -77,7 +77,7 @@
<span id="L15"><span class="lineNum"> 15</span> : class Ensemble : public Classifier {</span>
<span id="L16"><span class="lineNum"> 16</span> : public:</span>
<span id="L17"><span class="lineNum"> 17</span> : Ensemble(bool predict_voting = true);</span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC tlaBgGNC"> 168 : virtual ~Ensemble() = default;</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC tlaBgGNC"> 56 : virtual ~Ensemble() = default;</span></span>
<span id="L19"><span class="lineNum"> 19</span> : torch::Tensor predict(torch::Tensor&amp; X) override;</span>
<span id="L20"><span class="lineNum"> 20</span> : std::vector&lt;int&gt; predict(std::vector&lt;std::vector&lt;int&gt;&gt;&amp; X) override;</span>
<span id="L21"><span class="lineNum"> 21</span> : torch::Tensor predict_proba(torch::Tensor&amp; X) override;</span>
@ -89,13 +89,13 @@
<span id="L27"><span class="lineNum"> 27</span> : int getNumberOfStates() const override;</span>
<span id="L28"><span class="lineNum"> 28</span> : std::vector&lt;std::string&gt; show() const override;</span>
<span id="L29"><span class="lineNum"> 29</span> : std::vector&lt;std::string&gt; graph(const std::string&amp; title) const override;</span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 18 : std::vector&lt;std::string&gt; topological_order() override</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 6 : std::vector&lt;std::string&gt; topological_order() override</span></span>
<span id="L31"><span class="lineNum"> 31</span> : {</span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 18 : return std::vector&lt;std::string&gt;();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 6 : return std::vector&lt;std::string&gt;();</span></span>
<span id="L33"><span class="lineNum"> 33</span> : }</span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 12 : std::string dump_cpt() const override</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 4 : std::string dump_cpt() const override</span></span>
<span id="L35"><span class="lineNum"> 35</span> : {</span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 24 : return &quot;&quot;;</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 8 : return &quot;&quot;;</span></span>
<span id="L37"><span class="lineNum"> 37</span> : }</span>
<span id="L38"><span class="lineNum"> 38</span> : protected:</span>
<span id="L39"><span class="lineNum"> 39</span> : torch::Tensor predict_average_voting(torch::Tensor&amp; X);</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,14 +65,14 @@
<tr>
<td class="coverFn"><a href="CFS.cc.gcov.html#L9">bayesnet::CFS::fit()</a></td>
<td class="coverFnHi">40</td>
<td class="coverFnHi">12</td>
</tr>
<tr>
<td class="coverFn"><a href="CFS.cc.gcov.html#L43">bayesnet::CFS::computeContinueCondition(std::vector&lt;int, std::allocator&lt;int&gt; &gt; const&amp;)</a></td>
<td class="coverFnHi">186</td>
<td class="coverFnHi">56</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,14 +65,14 @@
<tr>
<td class="coverFn"><a href="CFS.cc.gcov.html#L43">bayesnet::CFS::computeContinueCondition(std::vector&lt;int, std::allocator&lt;int&gt; &gt; const&amp;)</a></td>
<td class="coverFnHi">186</td>
<td class="coverFnHi">56</td>
</tr>
<tr>
<td class="coverFn"><a href="CFS.cc.gcov.html#L9">bayesnet::CFS::fit()</a></td>
<td class="coverFnHi">40</td>
<td class="coverFnHi">12</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -70,46 +70,46 @@
<span id="L8"><span class="lineNum"> 8</span> : #include &quot;bayesnet/utils/bayesnetUtils.h&quot;</span>
<span id="L9"><span class="lineNum"> 9</span> : #include &quot;CFS.h&quot;</span>
<span id="L10"><span class="lineNum"> 10</span> : namespace bayesnet {</span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 40 : void CFS::fit()</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 12 : void CFS::fit()</span></span>
<span id="L12"><span class="lineNum"> 12</span> : {</span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 40 : initialize();</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 40 : computeSuLabels();</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 40 : auto featureOrder = argsort(suLabels); // sort descending order</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 40 : auto continueCondition = true;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 40 : auto feature = featureOrder[0];</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 40 : selectedFeatures.push_back(feature);</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 40 : selectedScores.push_back(suLabels[feature]);</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 40 : featureOrder.erase(featureOrder.begin());</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 226 : while (continueCondition) {</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 186 : double merit = std::numeric_limits&lt;double&gt;::lowest();</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 186 : int bestFeature = -1;</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 1083 : for (auto feature : featureOrder) {</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 897 : selectedFeatures.push_back(feature);</span></span>
<span id="L13"><span class="lineNum"> 13</span> <span class="tlaGNC"> 12 : initialize();</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 12 : computeSuLabels();</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 12 : auto featureOrder = argsort(suLabels); // sort descending order</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 12 : auto continueCondition = true;</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 12 : auto feature = featureOrder[0];</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 12 : selectedFeatures.push_back(feature);</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 12 : selectedScores.push_back(suLabels[feature]);</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 12 : featureOrder.erase(featureOrder.begin());</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 68 : while (continueCondition) {</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 56 : double merit = std::numeric_limits&lt;double&gt;::lowest();</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 56 : int bestFeature = -1;</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 328 : for (auto feature : featureOrder) {</span></span>
<span id="L25"><span class="lineNum"> 25</span> <span class="tlaGNC"> 272 : selectedFeatures.push_back(feature);</span></span>
<span id="L26"><span class="lineNum"> 26</span> : // Compute merit with selectedFeatures</span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 897 : auto meritNew = computeMeritCFS();</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 897 : if (meritNew &gt; merit) {</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 379 : merit = meritNew;</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 379 : bestFeature = feature;</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 272 : auto meritNew = computeMeritCFS();</span></span>
<span id="L28"><span class="lineNum"> 28</span> <span class="tlaGNC"> 272 : if (meritNew &gt; merit) {</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 114 : merit = meritNew;</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 114 : bestFeature = feature;</span></span>
<span id="L31"><span class="lineNum"> 31</span> : }</span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 897 : selectedFeatures.pop_back();</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 272 : selectedFeatures.pop_back();</span></span>
<span id="L33"><span class="lineNum"> 33</span> : }</span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 186 : if (bestFeature == -1) {</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 56 : if (bestFeature == -1) {</span></span>
<span id="L35"><span class="lineNum"> 35</span> : // meritNew has to be nan due to constant features</span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaUNC tlaBgUNC"> 0 : break;</span></span>
<span id="L37"><span class="lineNum"> 37</span> : }</span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC tlaBgGNC"> 186 : selectedFeatures.push_back(bestFeature);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 186 : selectedScores.push_back(merit);</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 186 : featureOrder.erase(remove(featureOrder.begin(), featureOrder.end(), bestFeature), featureOrder.end());</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 186 : continueCondition = computeContinueCondition(featureOrder);</span></span>
<span id="L38"><span class="lineNum"> 38</span> <span class="tlaGNC tlaBgGNC"> 56 : selectedFeatures.push_back(bestFeature);</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 56 : selectedScores.push_back(merit);</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 56 : featureOrder.erase(remove(featureOrder.begin(), featureOrder.end(), bestFeature), featureOrder.end());</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 56 : continueCondition = computeContinueCondition(featureOrder);</span></span>
<span id="L42"><span class="lineNum"> 42</span> : }</span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 40 : fitted = true;</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 40 : }</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 186 : bool CFS::computeContinueCondition(const std::vector&lt;int&gt;&amp; featureOrder)</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 12 : fitted = true;</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 12 : }</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaGNC"> 56 : bool CFS::computeContinueCondition(const std::vector&lt;int&gt;&amp; featureOrder)</span></span>
<span id="L46"><span class="lineNum"> 46</span> : {</span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 186 : if (selectedFeatures.size() == maxFeatures || featureOrder.size() == 0) {</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 7 : return false;</span></span>
<span id="L47"><span class="lineNum"> 47</span> <span class="tlaGNC"> 56 : if (selectedFeatures.size() == maxFeatures || featureOrder.size() == 0) {</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC"> 2 : return false;</span></span>
<span id="L49"><span class="lineNum"> 49</span> : }</span>
<span id="L50"><span class="lineNum"> 50</span> <span class="tlaGNC"> 179 : if (selectedScores.size() &gt;= 5) {</span></span>
<span id="L50"><span class="lineNum"> 50</span> <span class="tlaGNC"> 54 : if (selectedScores.size() &gt;= 5) {</span></span>
<span id="L51"><span class="lineNum"> 51</span> : /*</span>
<span id="L52"><span class="lineNum"> 52</span> : &quot;To prevent the best first search from exploring the entire</span>
<span id="L53"><span class="lineNum"> 53</span> : feature subset search space, a stopping criterion is imposed.</span>
@ -117,25 +117,25 @@
<span id="L55"><span class="lineNum"> 55</span> : subsets show no improvement over the current best subset.&quot;</span>
<span id="L56"><span class="lineNum"> 56</span> : as stated in Mark A.Hall Thesis</span>
<span id="L57"><span class="lineNum"> 57</span> : */</span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 66 : double item_ant = std::numeric_limits&lt;double&gt;::lowest();</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 66 : int num = 0;</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 66 : std::vector&lt;double&gt; lastFive(selectedScores.end() - 5, selectedScores.end());</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 264 : for (auto item : lastFive) {</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 231 : if (item_ant == std::numeric_limits&lt;double&gt;::lowest()) {</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 66 : item_ant = item;</span></span>
<span id="L58"><span class="lineNum"> 58</span> <span class="tlaGNC"> 20 : double item_ant = std::numeric_limits&lt;double&gt;::lowest();</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 20 : int num = 0;</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 20 : std::vector&lt;double&gt; lastFive(selectedScores.end() - 5, selectedScores.end());</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 80 : for (auto item : lastFive) {</span></span>
<span id="L62"><span class="lineNum"> 62</span> <span class="tlaGNC"> 70 : if (item_ant == std::numeric_limits&lt;double&gt;::lowest()) {</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 20 : item_ant = item;</span></span>
<span id="L64"><span class="lineNum"> 64</span> : }</span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 231 : if (item &gt; item_ant) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 33 : break;</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 70 : if (item &gt; item_ant) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 10 : break;</span></span>
<span id="L67"><span class="lineNum"> 67</span> : } else {</span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 198 : num++;</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 198 : item_ant = item;</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 60 : num++;</span></span>
<span id="L69"><span class="lineNum"> 69</span> <span class="tlaGNC"> 60 : item_ant = item;</span></span>
<span id="L70"><span class="lineNum"> 70</span> : }</span>
<span id="L71"><span class="lineNum"> 71</span> : }</span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 66 : if (num == 5) {</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 33 : return false;</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 20 : if (num == 5) {</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 10 : return false;</span></span>
<span id="L74"><span class="lineNum"> 74</span> : }</span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 66 : }</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 146 : return true;</span></span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 20 : }</span></span>
<span id="L76"><span class="lineNum"> 76</span> <span class="tlaGNC"> 44 : return true;</span></span>
<span id="L77"><span class="lineNum"> 77</span> : }</span>
<span id="L78"><span class="lineNum"> 78</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,14 +65,14 @@
<tr>
<td class="coverFn"><a href="CFS.h.gcov.html#L14">bayesnet::CFS::CFS(at::Tensor const&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int, int, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">26</td>
<td class="coverFnHi">14</td>
</tr>
<tr>
<td class="coverFn"><a href="CFS.h.gcov.html#L18">bayesnet::CFS::~CFS()</a></td>
<td class="coverFnHi">88</td>
<td class="coverFnHi">28</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,14 +65,14 @@
<tr>
<td class="coverFn"><a href="CFS.h.gcov.html#L14">bayesnet::CFS::CFS(at::Tensor const&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int, int, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">26</td>
<td class="coverFnHi">14</td>
</tr>
<tr>
<td class="coverFn"><a href="CFS.h.gcov.html#L18">bayesnet::CFS::~CFS()</a></td>
<td class="coverFnHi">88</td>
<td class="coverFnHi">28</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -75,11 +75,11 @@
<span id="L13"><span class="lineNum"> 13</span> : class CFS : public FeatureSelect {</span>
<span id="L14"><span class="lineNum"> 14</span> : public:</span>
<span id="L15"><span class="lineNum"> 15</span> : // dataset is a n+1xm tensor of integers where dataset[-1] is the y std::vector</span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC tlaBgGNC"> 26 : CFS(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights) :</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 26 : FeatureSelect(samples, features, className, maxFeatures, classNumStates, weights)</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC tlaBgGNC"> 14 : CFS(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights) :</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 14 : FeatureSelect(samples, features, className, maxFeatures, classNumStates, weights)</span></span>
<span id="L18"><span class="lineNum"> 18</span> : {</span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 26 : }</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 88 : virtual ~CFS() {};</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 14 : }</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 28 : virtual ~CFS() {};</span></span>
<span id="L21"><span class="lineNum"> 21</span> : void fit() override;</span>
<span id="L22"><span class="lineNum"> 22</span> : private:</span>
<span id="L23"><span class="lineNum"> 23</span> : bool computeContinueCondition(const std::vector&lt;int&gt;&amp; featureOrder);</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,14 +65,14 @@
<tr>
<td class="coverFn"><a href="FCBF.cc.gcov.html#L16">bayesnet::FCBF::fit()</a></td>
<td class="coverFnHi">34</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="FCBF.cc.gcov.html#L9">bayesnet::FCBF::FCBF(at::Tensor const&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int, int, at::Tensor const&amp;, double)</a></td>
<td class="coverFnHi">48</td>
<td class="coverFnHi">14</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,14 +65,14 @@
<tr>
<td class="coverFn"><a href="FCBF.cc.gcov.html#L9">bayesnet::FCBF::FCBF(at::Tensor const&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int, int, at::Tensor const&amp;, double)</a></td>
<td class="coverFnHi">48</td>
<td class="coverFnHi">14</td>
</tr>
<tr>
<td class="coverFn"><a href="FCBF.cc.gcov.html#L16">bayesnet::FCBF::fit()</a></td>
<td class="coverFnHi">34</td>
<td class="coverFnHi">10</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -70,45 +70,45 @@
<span id="L8"><span class="lineNum"> 8</span> : #include &quot;FCBF.h&quot;</span>
<span id="L9"><span class="lineNum"> 9</span> : namespace bayesnet {</span>
<span id="L10"><span class="lineNum"> 10</span> : </span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 48 : FCBF::FCBF(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights, const double threshold) :</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 48 : FeatureSelect(samples, features, className, maxFeatures, classNumStates, weights), threshold(threshold)</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 14 : FCBF::FCBF(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights, const double threshold) :</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 14 : FeatureSelect(samples, features, className, maxFeatures, classNumStates, weights), threshold(threshold)</span></span>
<span id="L13"><span class="lineNum"> 13</span> : {</span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 48 : if (threshold &lt; 1e-7) {</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 14 : throw std::invalid_argument(&quot;Threshold cannot be less than 1e-7&quot;);</span></span>
<span id="L14"><span class="lineNum"> 14</span> <span class="tlaGNC"> 14 : if (threshold &lt; 1e-7) {</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 4 : throw std::invalid_argument(&quot;Threshold cannot be less than 1e-7&quot;);</span></span>
<span id="L16"><span class="lineNum"> 16</span> : }</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 48 : }</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 34 : void FCBF::fit()</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC"> 14 : }</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 10 : void FCBF::fit()</span></span>
<span id="L19"><span class="lineNum"> 19</span> : {</span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 34 : initialize();</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 34 : computeSuLabels();</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 34 : auto featureOrder = argsort(suLabels); // sort descending order</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 34 : auto featureOrderCopy = featureOrder;</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 284 : for (const auto&amp; feature : featureOrder) {</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 10 : initialize();</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 10 : computeSuLabels();</span></span>
<span id="L22"><span class="lineNum"> 22</span> <span class="tlaGNC"> 10 : auto featureOrder = argsort(suLabels); // sort descending order</span></span>
<span id="L23"><span class="lineNum"> 23</span> <span class="tlaGNC"> 10 : auto featureOrderCopy = featureOrder;</span></span>
<span id="L24"><span class="lineNum"> 24</span> <span class="tlaGNC"> 84 : for (const auto&amp; feature : featureOrder) {</span></span>
<span id="L25"><span class="lineNum"> 25</span> : // Don't self compare</span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 250 : featureOrderCopy.erase(featureOrderCopy.begin());</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 250 : if (suLabels.at(feature) == 0.0) {</span></span>
<span id="L26"><span class="lineNum"> 26</span> <span class="tlaGNC"> 74 : featureOrderCopy.erase(featureOrderCopy.begin());</span></span>
<span id="L27"><span class="lineNum"> 27</span> <span class="tlaGNC"> 74 : if (suLabels.at(feature) == 0.0) {</span></span>
<span id="L28"><span class="lineNum"> 28</span> : // The feature has been removed from the list</span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 108 : continue;</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 32 : continue;</span></span>
<span id="L30"><span class="lineNum"> 30</span> : }</span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 142 : if (suLabels.at(feature) &lt; threshold) {</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 42 : if (suLabels.at(feature) &lt; threshold) {</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaUNC tlaBgUNC"> 0 : break;</span></span>
<span id="L33"><span class="lineNum"> 33</span> : }</span>
<span id="L34"><span class="lineNum"> 34</span> : // Remove redundant features</span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC tlaBgGNC"> 781 : for (const auto&amp; featureCopy : featureOrderCopy) {</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 639 : double value = computeSuFeatures(feature, featureCopy);</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 639 : if (value &gt;= suLabels.at(featureCopy)) {</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC tlaBgGNC"> 232 : for (const auto&amp; featureCopy : featureOrderCopy) {</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 190 : double value = computeSuFeatures(feature, featureCopy);</span></span>
<span id="L37"><span class="lineNum"> 37</span> <span class="tlaGNC"> 190 : if (value &gt;= suLabels.at(featureCopy)) {</span></span>
<span id="L38"><span class="lineNum"> 38</span> : // Remove feature from list</span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 221 : suLabels[featureCopy] = 0.0;</span></span>
<span id="L39"><span class="lineNum"> 39</span> <span class="tlaGNC"> 66 : suLabels[featureCopy] = 0.0;</span></span>
<span id="L40"><span class="lineNum"> 40</span> : }</span>
<span id="L41"><span class="lineNum"> 41</span> : }</span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 142 : selectedFeatures.push_back(feature);</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 142 : selectedScores.push_back(suLabels[feature]);</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 142 : if (selectedFeatures.size() == maxFeatures) {</span></span>
<span id="L42"><span class="lineNum"> 42</span> <span class="tlaGNC"> 42 : selectedFeatures.push_back(feature);</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 42 : selectedScores.push_back(suLabels[feature]);</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 42 : if (selectedFeatures.size() == maxFeatures) {</span></span>
<span id="L45"><span class="lineNum"> 45</span> <span class="tlaUNC tlaBgUNC"> 0 : break;</span></span>
<span id="L46"><span class="lineNum"> 46</span> : }</span>
<span id="L47"><span class="lineNum"> 47</span> : }</span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC tlaBgGNC"> 34 : fitted = true;</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 34 : }</span></span>
<span id="L48"><span class="lineNum"> 48</span> <span class="tlaGNC tlaBgGNC"> 10 : fitted = true;</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 10 : }</span></span>
<span id="L50"><span class="lineNum"> 50</span> : }</span>
</pre>
</td>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="FCBF.h.gcov.html#L15">bayesnet::FCBF::~FCBF()</a></td>
<td class="coverFnHi">38</td>
<td class="coverFnHi">20</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="FCBF.h.gcov.html#L15">bayesnet::FCBF::~FCBF()</a></td>
<td class="coverFnHi">38</td>
<td class="coverFnHi">20</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -76,7 +76,7 @@
<span id="L14"><span class="lineNum"> 14</span> : public:</span>
<span id="L15"><span class="lineNum"> 15</span> : // dataset is a n+1xm tensor of integers where dataset[-1] is the y std::vector</span>
<span id="L16"><span class="lineNum"> 16</span> : FCBF(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights, const double threshold);</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 38 : virtual ~FCBF() {};</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 20 : virtual ~FCBF() {};</span></span>
<span id="L18"><span class="lineNum"> 18</span> : void fit() override;</span>
<span id="L19"><span class="lineNum"> 19</span> : private:</span>
<span id="L20"><span class="lineNum"> 20</span> : double threshold = -1;</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,56 +65,56 @@
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L34">bayesnet::FeatureSelect::computeSuLabels()</a></td>
<td class="coverFnHi">108</td>
<td class="coverFnHi">32</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L14">bayesnet::FeatureSelect::initialize()</a></td>
<td class="coverFnHi">108</td>
<td class="coverFnHi">32</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L68">bayesnet::FeatureSelect::getFeatures() const</a></td>
<td class="coverFnHi">116</td>
<td class="coverFnHi">36</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L75">bayesnet::FeatureSelect::getScores() const</a></td>
<td class="coverFnHi">116</td>
<td class="coverFnHi">36</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L9">bayesnet::FeatureSelect::FeatureSelect(at::Tensor const&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int, int, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">154</td>
<td class="coverFnHi">46</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L55">bayesnet::FeatureSelect::computeMeritCFS()</a></td>
<td class="coverFnHi">1047</td>
<td class="coverFnHi">316</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L19">bayesnet::FeatureSelect::symmetricalUncertainty(int, int)</a></td>
<td class="coverFnHi">2751</td>
<td class="coverFnHi">822</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L42">bayesnet::FeatureSelect::computeSuFeatures(int, int)</a></td>
<td class="coverFnHi">6499</td>
<td class="coverFnHi">1960</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,56 +65,56 @@
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L9">bayesnet::FeatureSelect::FeatureSelect(at::Tensor const&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int, int, at::Tensor const&amp;)</a></td>
<td class="coverFnHi">154</td>
<td class="coverFnHi">46</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L55">bayesnet::FeatureSelect::computeMeritCFS()</a></td>
<td class="coverFnHi">1047</td>
<td class="coverFnHi">316</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L42">bayesnet::FeatureSelect::computeSuFeatures(int, int)</a></td>
<td class="coverFnHi">6499</td>
<td class="coverFnHi">1960</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L34">bayesnet::FeatureSelect::computeSuLabels()</a></td>
<td class="coverFnHi">108</td>
<td class="coverFnHi">32</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L68">bayesnet::FeatureSelect::getFeatures() const</a></td>
<td class="coverFnHi">116</td>
<td class="coverFnHi">36</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L75">bayesnet::FeatureSelect::getScores() const</a></td>
<td class="coverFnHi">116</td>
<td class="coverFnHi">36</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L14">bayesnet::FeatureSelect::initialize()</a></td>
<td class="coverFnHi">108</td>
<td class="coverFnHi">32</td>
</tr>
<tr>
<td class="coverFn"><a href="FeatureSelect.cc.gcov.html#L19">bayesnet::FeatureSelect::symmetricalUncertainty(int, int)</a></td>
<td class="coverFnHi">2751</td>
<td class="coverFnHi">822</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -70,17 +70,17 @@
<span id="L8"><span class="lineNum"> 8</span> : #include &quot;bayesnet/utils/bayesnetUtils.h&quot;</span>
<span id="L9"><span class="lineNum"> 9</span> : #include &quot;FeatureSelect.h&quot;</span>
<span id="L10"><span class="lineNum"> 10</span> : namespace bayesnet {</span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 154 : FeatureSelect::FeatureSelect(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights) :</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 154 : Metrics(samples, features, className, classNumStates), maxFeatures(maxFeatures == 0 ? samples.size(0) - 1 : maxFeatures), weights(weights)</span></span>
<span id="L11"><span class="lineNum"> 11</span> <span class="tlaGNC tlaBgGNC"> 46 : FeatureSelect::FeatureSelect(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights) :</span></span>
<span id="L12"><span class="lineNum"> 12</span> <span class="tlaGNC"> 46 : Metrics(samples, features, className, classNumStates), maxFeatures(maxFeatures == 0 ? samples.size(0) - 1 : maxFeatures), weights(weights)</span></span>
<span id="L13"><span class="lineNum"> 13</span> : </span>
<span id="L14"><span class="lineNum"> 14</span> : {</span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 154 : }</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 108 : void FeatureSelect::initialize()</span></span>
<span id="L15"><span class="lineNum"> 15</span> <span class="tlaGNC"> 46 : }</span></span>
<span id="L16"><span class="lineNum"> 16</span> <span class="tlaGNC"> 32 : void FeatureSelect::initialize()</span></span>
<span id="L17"><span class="lineNum"> 17</span> : {</span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 108 : selectedFeatures.clear();</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 108 : selectedScores.clear();</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 108 : }</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 2751 : double FeatureSelect::symmetricalUncertainty(int a, int b)</span></span>
<span id="L18"><span class="lineNum"> 18</span> <span class="tlaGNC"> 32 : selectedFeatures.clear();</span></span>
<span id="L19"><span class="lineNum"> 19</span> <span class="tlaGNC"> 32 : selectedScores.clear();</span></span>
<span id="L20"><span class="lineNum"> 20</span> <span class="tlaGNC"> 32 : }</span></span>
<span id="L21"><span class="lineNum"> 21</span> <span class="tlaGNC"> 822 : double FeatureSelect::symmetricalUncertainty(int a, int b)</span></span>
<span id="L22"><span class="lineNum"> 22</span> : {</span>
<span id="L23"><span class="lineNum"> 23</span> : /*</span>
<span id="L24"><span class="lineNum"> 24</span> : Compute symmetrical uncertainty. Normalize* information gain (mutual</span>
@ -88,60 +88,60 @@
<span id="L26"><span class="lineNum"> 26</span> : the bias due to high cardinality features. *Range [0, 1]</span>
<span id="L27"><span class="lineNum"> 27</span> : (https://www.sciencedirect.com/science/article/pii/S0020025519303603)</span>
<span id="L28"><span class="lineNum"> 28</span> : */</span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 8253 : auto x = samples.index({ a, &quot;...&quot; });</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 8253 : auto y = samples.index({ b, &quot;...&quot; });</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 2751 : auto mu = mutualInformation(x, y, weights);</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 2751 : auto hx = entropy(x, weights);</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 2751 : auto hy = entropy(y, weights);</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 2751 : return 2.0 * mu / (hx + hy);</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 8253 : }</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 108 : void FeatureSelect::computeSuLabels()</span></span>
<span id="L29"><span class="lineNum"> 29</span> <span class="tlaGNC"> 2466 : auto x = samples.index({ a, &quot;...&quot; });</span></span>
<span id="L30"><span class="lineNum"> 30</span> <span class="tlaGNC"> 2466 : auto y = samples.index({ b, &quot;...&quot; });</span></span>
<span id="L31"><span class="lineNum"> 31</span> <span class="tlaGNC"> 822 : auto mu = mutualInformation(x, y, weights);</span></span>
<span id="L32"><span class="lineNum"> 32</span> <span class="tlaGNC"> 822 : auto hx = entropy(x, weights);</span></span>
<span id="L33"><span class="lineNum"> 33</span> <span class="tlaGNC"> 822 : auto hy = entropy(y, weights);</span></span>
<span id="L34"><span class="lineNum"> 34</span> <span class="tlaGNC"> 822 : return 2.0 * mu / (hx + hy);</span></span>
<span id="L35"><span class="lineNum"> 35</span> <span class="tlaGNC"> 2466 : }</span></span>
<span id="L36"><span class="lineNum"> 36</span> <span class="tlaGNC"> 32 : void FeatureSelect::computeSuLabels()</span></span>
<span id="L37"><span class="lineNum"> 37</span> : {</span>
<span id="L38"><span class="lineNum"> 38</span> : // Compute Simmetrical Uncertainty between features and labels</span>
<span id="L39"><span class="lineNum"> 39</span> : // https://en.wikipedia.org/wiki/Symmetric_uncertainty</span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 906 : for (int i = 0; i &lt; features.size(); ++i) {</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 798 : suLabels.push_back(symmetricalUncertainty(i, -1));</span></span>
<span id="L40"><span class="lineNum"> 40</span> <span class="tlaGNC"> 270 : for (int i = 0; i &lt; features.size(); ++i) {</span></span>
<span id="L41"><span class="lineNum"> 41</span> <span class="tlaGNC"> 238 : suLabels.push_back(symmetricalUncertainty(i, -1));</span></span>
<span id="L42"><span class="lineNum"> 42</span> : }</span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 108 : }</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 6499 : double FeatureSelect::computeSuFeatures(const int firstFeature, const int secondFeature)</span></span>
<span id="L43"><span class="lineNum"> 43</span> <span class="tlaGNC"> 32 : }</span></span>
<span id="L44"><span class="lineNum"> 44</span> <span class="tlaGNC"> 1960 : double FeatureSelect::computeSuFeatures(const int firstFeature, const int secondFeature)</span></span>
<span id="L45"><span class="lineNum"> 45</span> : {</span>
<span id="L46"><span class="lineNum"> 46</span> : // Compute Simmetrical Uncertainty between features</span>
<span id="L47"><span class="lineNum"> 47</span> : // https://en.wikipedia.org/wiki/Symmetric_uncertainty</span>
<span id="L48"><span class="lineNum"> 48</span> : try {</span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 6499 : return suFeatures.at({ firstFeature, secondFeature });</span></span>
<span id="L49"><span class="lineNum"> 49</span> <span class="tlaGNC"> 1960 : return suFeatures.at({ firstFeature, secondFeature });</span></span>
<span id="L50"><span class="lineNum"> 50</span> : }</span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 1953 : catch (const std::out_of_range&amp; e) {</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 1953 : double result = symmetricalUncertainty(firstFeature, secondFeature);</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 1953 : suFeatures[{firstFeature, secondFeature}] = result;</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 1953 : return result;</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 1953 : }</span></span>
<span id="L51"><span class="lineNum"> 51</span> <span class="tlaGNC"> 584 : catch (const std::out_of_range&amp; e) {</span></span>
<span id="L52"><span class="lineNum"> 52</span> <span class="tlaGNC"> 584 : double result = symmetricalUncertainty(firstFeature, secondFeature);</span></span>
<span id="L53"><span class="lineNum"> 53</span> <span class="tlaGNC"> 584 : suFeatures[{firstFeature, secondFeature}] = result;</span></span>
<span id="L54"><span class="lineNum"> 54</span> <span class="tlaGNC"> 584 : return result;</span></span>
<span id="L55"><span class="lineNum"> 55</span> <span class="tlaGNC"> 584 : }</span></span>
<span id="L56"><span class="lineNum"> 56</span> : }</span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 1047 : double FeatureSelect::computeMeritCFS()</span></span>
<span id="L57"><span class="lineNum"> 57</span> <span class="tlaGNC"> 316 : double FeatureSelect::computeMeritCFS()</span></span>
<span id="L58"><span class="lineNum"> 58</span> : {</span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 1047 : double rcf = 0;</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 4816 : for (auto feature : selectedFeatures) {</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 3769 : rcf += suLabels[feature];</span></span>
<span id="L59"><span class="lineNum"> 59</span> <span class="tlaGNC"> 316 : double rcf = 0;</span></span>
<span id="L60"><span class="lineNum"> 60</span> <span class="tlaGNC"> 1454 : for (auto feature : selectedFeatures) {</span></span>
<span id="L61"><span class="lineNum"> 61</span> <span class="tlaGNC"> 1138 : rcf += suLabels[feature];</span></span>
<span id="L62"><span class="lineNum"> 62</span> : }</span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 1047 : double rff = 0;</span></span>
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 1047 : int n = selectedFeatures.size();</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 6907 : for (const auto&amp; item : doCombinations(selectedFeatures)) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 5860 : rff += computeSuFeatures(item.first, item.second);</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 1047 : }</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 1047 : return rcf / sqrt(n + (n * n - n) * rff);</span></span>
<span id="L63"><span class="lineNum"> 63</span> <span class="tlaGNC"> 316 : double rff = 0;</span></span>
<span id="L64"><span class="lineNum"> 64</span> <span class="tlaGNC"> 316 : int n = selectedFeatures.size();</span></span>
<span id="L65"><span class="lineNum"> 65</span> <span class="tlaGNC"> 2086 : for (const auto&amp; item : doCombinations(selectedFeatures)) {</span></span>
<span id="L66"><span class="lineNum"> 66</span> <span class="tlaGNC"> 1770 : rff += computeSuFeatures(item.first, item.second);</span></span>
<span id="L67"><span class="lineNum"> 67</span> <span class="tlaGNC"> 316 : }</span></span>
<span id="L68"><span class="lineNum"> 68</span> <span class="tlaGNC"> 316 : return rcf / sqrt(n + (n * n - n) * rff);</span></span>
<span id="L69"><span class="lineNum"> 69</span> : }</span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 116 : std::vector&lt;int&gt; FeatureSelect::getFeatures() const</span></span>
<span id="L70"><span class="lineNum"> 70</span> <span class="tlaGNC"> 36 : std::vector&lt;int&gt; FeatureSelect::getFeatures() const</span></span>
<span id="L71"><span class="lineNum"> 71</span> : {</span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 116 : if (!fitted) {</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 8 : throw std::runtime_error(&quot;FeatureSelect not fitted&quot;);</span></span>
<span id="L72"><span class="lineNum"> 72</span> <span class="tlaGNC"> 36 : if (!fitted) {</span></span>
<span id="L73"><span class="lineNum"> 73</span> <span class="tlaGNC"> 4 : throw std::runtime_error(&quot;FeatureSelect not fitted&quot;);</span></span>
<span id="L74"><span class="lineNum"> 74</span> : }</span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 108 : return selectedFeatures;</span></span>
<span id="L75"><span class="lineNum"> 75</span> <span class="tlaGNC"> 32 : return selectedFeatures;</span></span>
<span id="L76"><span class="lineNum"> 76</span> : }</span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 116 : std::vector&lt;double&gt; FeatureSelect::getScores() const</span></span>
<span id="L77"><span class="lineNum"> 77</span> <span class="tlaGNC"> 36 : std::vector&lt;double&gt; FeatureSelect::getScores() const</span></span>
<span id="L78"><span class="lineNum"> 78</span> : {</span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 116 : if (!fitted) {</span></span>
<span id="L80"><span class="lineNum"> 80</span> <span class="tlaGNC"> 8 : throw std::runtime_error(&quot;FeatureSelect not fitted&quot;);</span></span>
<span id="L79"><span class="lineNum"> 79</span> <span class="tlaGNC"> 36 : if (!fitted) {</span></span>
<span id="L80"><span class="lineNum"> 80</span> <span class="tlaGNC"> 4 : throw std::runtime_error(&quot;FeatureSelect not fitted&quot;);</span></span>
<span id="L81"><span class="lineNum"> 81</span> : }</span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 108 : return selectedScores;</span></span>
<span id="L82"><span class="lineNum"> 82</span> <span class="tlaGNC"> 32 : return selectedScores;</span></span>
<span id="L83"><span class="lineNum"> 83</span> : }</span>
<span id="L84"><span class="lineNum"> 84</span> : }</span>
</pre>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="FeatureSelect.h.gcov.html#L15">bayesnet::FeatureSelect::~FeatureSelect()</a></td>
<td class="coverFnHi">88</td>
<td class="coverFnHi">46</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,7 +65,7 @@
<tr>
<td class="coverFn"><a href="FeatureSelect.h.gcov.html#L15">bayesnet::FeatureSelect::~FeatureSelect()</a></td>
<td class="coverFnHi">88</td>
<td class="coverFnHi">46</td>
</tr>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -76,7 +76,7 @@
<span id="L14"><span class="lineNum"> 14</span> : public:</span>
<span id="L15"><span class="lineNum"> 15</span> : // dataset is a n+1xm tensor of integers where dataset[-1] is the y std::vector</span>
<span id="L16"><span class="lineNum"> 16</span> : FeatureSelect(const torch::Tensor&amp; samples, const std::vector&lt;std::string&gt;&amp; features, const std::string&amp; className, const int maxFeatures, const int classNumStates, const torch::Tensor&amp; weights);</span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 88 : virtual ~FeatureSelect() {};</span></span>
<span id="L17"><span class="lineNum"> 17</span> <span class="tlaGNC tlaBgGNC"> 46 : virtual ~FeatureSelect() {};</span></span>
<span id="L18"><span class="lineNum"> 18</span> : virtual void fit() = 0;</span>
<span id="L19"><span class="lineNum"> 19</span> : std::vector&lt;int&gt; getFeatures() const;</span>
<span id="L20"><span class="lineNum"> 20</span> : std::vector&lt;double&gt; getScores() const;</span>

View File

@ -37,7 +37,7 @@
</tr>
<tr>
<td class="headerItem">Test Date:</td>
<td class="headerValue">2024-04-30 13:59:18</td>
<td class="headerValue">2024-04-30 20:26:57</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntryHi">100.0&nbsp;%</td>
@ -65,14 +65,14 @@
<tr>
<td class="coverFn"><a href="IWSS.cc.gcov.html#L16">bayesnet::IWSS::fit()</a></td>
<td class="coverFnHi">34</td>
<td class="coverFnHi">10</td>
</tr>
<tr>
<td class="coverFn"><a href="IWSS.cc.gcov.html#L9">bayesnet::IWSS::IWSS(at::Tensor const&amp;, std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, int, int, at::Tensor const&amp;, double)</a></td>
<td class="coverFnHi">62</td>
<td class="coverFnHi">18</td>
</tr>

Some files were not shown because too many files have changed in this diff Show More