Files
BayesNet/docs/manual/_t_a_n_ld_8cc_source.html

9.7 KiB

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <script type="text/javascript" src="clipboard.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="cookie.js"></script> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> </head>
BayesNet 1.0.5
Bayesian Network Classifiers using libtorch from scratch
<script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ var searchBox = new SearchBox("searchBox", "search/",'.html'); /* @license-end */ </script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { codefold.init(0); }); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { initMenu('',true,false,'search.php','Search',true); $(function() { init_search(); }); }); /* @license-end */ </script>
<script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function(){initNavTree('_t_a_n_ld_8cc_source.html',''); initResizable(true); }); /* @license-end */ </script>
Loading...
Searching...
No Matches
TANLd.cc
1// ***************************************************************
2// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
3// SPDX-FileType: SOURCE
4// SPDX-License-Identifier: MIT
5// ***************************************************************
6
7#include "TANLd.h"
8
9namespace bayesnet {
10 TANLd::TANLd() : TAN(), Proposal(dataset, features, className) {}
11 TANLd& TANLd::fit(torch::Tensor& X_, torch::Tensor& y_, const std::vector<std::string>& features_, const std::string& className_, map<std::string, std::vector<int>>& states_)
12 {
13 checkInput(X_, y_);
14 features = features_;
15 className = className_;
16 Xf = X_;
17 y = y_;
18 // Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y
19 states = fit_local_discretization(y);
20 // We have discretized the input data
21 // 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
22 TAN::fit(dataset, features, className, states);
23 states = localDiscretizationProposal(states, model);
24 return *this;
25
26 }
27 torch::Tensor TANLd::predict(torch::Tensor& X)
28 {
29 auto Xt = prepareX(X);
30 return TAN::predict(Xt);
31 }
32 std::vector<std::string> TANLd::graph(const std::string& name) const
33 {
34 return TAN::graph(name);
35 }
36}
</html>