7.4 KiB
7.4 KiB
<html lang="en">
<head>
</head>
</html>
LCOV - code coverage report | ||||||||||||||||||||||
![]() | ||||||||||||||||||||||
|
||||||||||||||||||||||
![]() |
Line data Source code 1 : // *************************************************************** 2 : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez 3 : // SPDX-FileType: SOURCE 4 : // SPDX-License-Identifier: MIT 5 : // *************************************************************** 6 : 7 : #include "KDBLd.h" 8 : 9 : namespace bayesnet { 10 187 : KDBLd::KDBLd(int k) : KDB(k), Proposal(dataset, features, className) {} 11 55 : KDBLd& KDBLd::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 55 : checkInput(X_, y_); 14 55 : features = features_; 15 55 : className = className_; 16 55 : Xf = X_; 17 55 : y = y_; 18 : // Fills std::vectors Xv & yv with the data from tensors X_ (discretized) & y 19 55 : states = fit_local_discretization(y); 20 : // We have discretized the input data 21 : // 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network 22 55 : KDB::fit(dataset, features, className, states); 23 55 : states = localDiscretizationProposal(states, model); 24 55 : return *this; 25 : } 26 44 : torch::Tensor KDBLd::predict(torch::Tensor& X) 27 : { 28 44 : auto Xt = prepareX(X); 29 88 : return KDB::predict(Xt); 30 44 : } 31 11 : std::vector<std::string> KDBLd::graph(const std::string& name) const 32 : { 33 11 : return KDB::graph(name); 34 : } 35 : } |
![]() |
Generated by: LCOV version 2.0-1 |
</html>