2024-04-11 16:02:49 +00:00
|
|
|
// ***************************************************************
|
|
|
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
|
|
|
// SPDX-FileType: SOURCE
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// ***************************************************************
|
|
|
|
|
2023-07-13 01:15:42 +00:00
|
|
|
#ifndef KDB_H
|
|
|
|
#define KDB_H
|
2023-08-15 13:04:56 +00:00
|
|
|
#include <torch/torch.h>
|
2024-03-08 21:20:54 +00:00
|
|
|
#include "bayesnet/utils/bayesnetUtils.h"
|
2023-07-22 21:07:56 +00:00
|
|
|
#include "Classifier.h"
|
2023-07-13 01:15:42 +00:00
|
|
|
namespace bayesnet {
|
2023-07-22 21:07:56 +00:00
|
|
|
class KDB : public Classifier {
|
2023-07-13 01:15:42 +00:00
|
|
|
private:
|
|
|
|
int k;
|
2023-07-13 08:58:27 +00:00
|
|
|
float theta;
|
2023-11-08 17:45:35 +00:00
|
|
|
void add_m_edges(int idx, std::vector<int>& S, torch::Tensor& weights);
|
2023-07-13 01:15:42 +00:00
|
|
|
protected:
|
2023-08-15 13:04:56 +00:00
|
|
|
void buildModel(const torch::Tensor& weights) override;
|
2023-07-13 01:15:42 +00:00
|
|
|
public:
|
2023-07-29 17:38:42 +00:00
|
|
|
explicit KDB(int k, float theta = 0.03);
|
2023-11-18 10:56:10 +00:00
|
|
|
virtual ~KDB() = default;
|
2024-04-07 22:55:30 +00:00
|
|
|
void setHyperparameters(const nlohmann::json& hyperparameters_) override;
|
2023-11-08 17:45:35 +00:00
|
|
|
std::vector<std::string> graph(const std::string& name = "KDB") const override;
|
2023-07-13 01:15:42 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|