Rename suffix of proposal classifier to Ld

This commit is contained in:
Ricardo Montañana Gómez 2023-08-05 23:23:31 +02:00
parent 1d0fd629c9
commit 9e94f4e140
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
12 changed files with 82 additions and 82 deletions

View File

@ -1,5 +1,5 @@
include_directories(${BayesNet_SOURCE_DIR}/lib/mdlp) include_directories(${BayesNet_SOURCE_DIR}/lib/mdlp)
include_directories(${BayesNet_SOURCE_DIR}/lib/Files) include_directories(${BayesNet_SOURCE_DIR}/lib/Files)
add_library(BayesNet bayesnetUtils.cc Network.cc Node.cc BayesMetrics.cc Classifier.cc add_library(BayesNet bayesnetUtils.cc Network.cc Node.cc BayesMetrics.cc Classifier.cc
KDB.cc TAN.cc SPODE.cc Ensemble.cc AODE.cc TANNew.cc KDBNew.cc SPODENew.cc Mst.cc Proposal.cc) KDB.cc TAN.cc SPODE.cc Ensemble.cc AODE.cc TANLd.cc KDBLd.cc SPODELd.cc Mst.cc Proposal.cc)
target_link_libraries(BayesNet mdlp ArffFiles "${TORCH_LIBRARIES}") target_link_libraries(BayesNet mdlp ArffFiles "${TORCH_LIBRARIES}")

View File

@ -1,9 +1,9 @@
#include "KDBNew.h" #include "KDBLd.h"
namespace bayesnet { namespace bayesnet {
using namespace std; using namespace std;
KDBNew::KDBNew(int k) : KDB(k), Proposal(KDB::Xv, KDB::yv, features, className) {} KDBLd::KDBLd(int k) : KDB(k), Proposal(KDB::Xv, KDB::yv, features, className) {}
KDBNew& KDBNew::fit(torch::Tensor& X_, torch::Tensor& y_, vector<string>& features_, string className_, map<string, vector<int>>& states_) KDBLd& KDBLd::fit(torch::Tensor& X_, torch::Tensor& y_, vector<string>& features_, string className_, map<string, vector<int>>& states_)
{ {
// This first part should go in a Classifier method called fit_local_discretization o fit_float... // This first part should go in a Classifier method called fit_local_discretization o fit_float...
features = features_; features = features_;
@ -23,12 +23,12 @@ namespace bayesnet {
model.fit(KDB::Xv, KDB::yv, features, className); model.fit(KDB::Xv, KDB::yv, features, className);
return *this; return *this;
} }
Tensor KDBNew::predict(Tensor& X) Tensor KDBLd::predict(Tensor& X)
{ {
auto Xt = prepareX(X); auto Xt = prepareX(X);
return KDB::predict(Xt); return KDB::predict(Xt);
} }
vector<string> KDBNew::graph(const string& name) vector<string> KDBLd::graph(const string& name)
{ {
return KDB::graph(name); return KDB::graph(name);
} }

19
src/BayesNet/KDBLd.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef KDBLD_H
#define KDBLD_H
#include "KDB.h"
#include "Proposal.h"
namespace bayesnet {
using namespace std;
class KDBLd : public KDB, public Proposal {
private:
public:
explicit KDBLd(int k);
virtual ~KDBLd() = default;
KDBLd& fit(torch::Tensor& X, torch::Tensor& y, vector<string>& features, string className, map<string, vector<int>>& states) override;
vector<string> graph(const string& name = "KDB") override;
Tensor predict(Tensor& X) override;
static inline string version() { return "0.0.1"; };
};
}
#endif // !KDBLD_H

View File

@ -1,19 +0,0 @@
#ifndef KDBNEW_H
#define KDBNEW_H
#include "KDB.h"
#include "Proposal.h"
namespace bayesnet {
using namespace std;
class KDBNew : public KDB, public Proposal {
private:
public:
explicit KDBNew(int k);
virtual ~KDBNew() = default;
KDBNew& fit(torch::Tensor& X, torch::Tensor& y, vector<string>& features, string className, map<string, vector<int>>& states) override;
vector<string> graph(const string& name = "KDB") override;
Tensor predict(Tensor& X) override;
static inline string version() { return "0.0.1"; };
};
}
#endif // !KDBNew_H

View File

@ -1,9 +1,9 @@
#include "SPODENew.h" #include "SPODELd.h"
namespace bayesnet { namespace bayesnet {
using namespace std; using namespace std;
SPODENew::SPODENew(int root) : SPODE(root), Proposal(SPODE::Xv, SPODE::yv, features, className) {} SPODELd::SPODELd(int root) : SPODE(root), Proposal(SPODE::Xv, SPODE::yv, features, className) {}
SPODENew& SPODENew::fit(torch::Tensor& X_, torch::Tensor& y_, vector<string>& features_, string className_, map<string, vector<int>>& states_) SPODELd& SPODELd::fit(torch::Tensor& X_, torch::Tensor& y_, vector<string>& features_, string className_, map<string, vector<int>>& states_)
{ {
// This first part should go in a Classifier method called fit_local_discretization o fit_float... // This first part should go in a Classifier method called fit_local_discretization o fit_float...
features = features_; features = features_;
@ -23,12 +23,12 @@ namespace bayesnet {
model.fit(SPODE::Xv, SPODE::yv, features, className); model.fit(SPODE::Xv, SPODE::yv, features, className);
return *this; return *this;
} }
Tensor SPODENew::predict(Tensor& X) Tensor SPODELd::predict(Tensor& X)
{ {
auto Xt = prepareX(X); auto Xt = prepareX(X);
return SPODE::predict(Xt); return SPODE::predict(Xt);
} }
vector<string> SPODENew::graph(const string& name) vector<string> SPODELd::graph(const string& name)
{ {
return SPODE::graph(name); return SPODE::graph(name);
} }

19
src/BayesNet/SPODELd.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef SPODELD_H
#define SPODELD_H
#include "SPODE.h"
#include "Proposal.h"
namespace bayesnet {
using namespace std;
class SPODELd : public SPODE, public Proposal {
private:
public:
explicit SPODELd(int root);
virtual ~SPODELd() = default;
SPODELd& fit(torch::Tensor& X, torch::Tensor& y, vector<string>& features, string className, map<string, vector<int>>& states) override;
vector<string> graph(const string& name = "SPODE") override;
Tensor predict(Tensor& X) override;
static inline string version() { return "0.0.1"; };
};
}
#endif // !SPODELD_H

View File

@ -1,19 +0,0 @@
#ifndef SPODENEW_H
#define SPODENEW_H
#include "SPODE.h"
#include "Proposal.h"
namespace bayesnet {
using namespace std;
class SPODENew : public SPODE, public Proposal {
private:
public:
explicit SPODENew(int root);
virtual ~SPODENew() = default;
SPODENew& fit(torch::Tensor& X, torch::Tensor& y, vector<string>& features, string className, map<string, vector<int>>& states) override;
vector<string> graph(const string& name = "SPODE") override;
Tensor predict(Tensor& X) override;
static inline string version() { return "0.0.1"; };
};
}
#endif // !SPODENew_H

View File

@ -1,9 +1,9 @@
#include "TANNew.h" #include "TANLd.h"
namespace bayesnet { namespace bayesnet {
using namespace std; using namespace std;
TANNew::TANNew() : TAN(), Proposal(TAN::Xv, TAN::yv, features, className) {} TANLd::TANLd() : TAN(), Proposal(TAN::Xv, TAN::yv, features, className) {}
TANNew& TANNew::fit(torch::Tensor& X_, torch::Tensor& y_, vector<string>& features_, string className_, map<string, vector<int>>& states_) TANLd& TANLd::fit(torch::Tensor& X_, torch::Tensor& y_, vector<string>& features_, string className_, map<string, vector<int>>& states_)
{ {
// This first part should go in a Classifier method called fit_local_discretization o fit_float... // This first part should go in a Classifier method called fit_local_discretization o fit_float...
features = features_; features = features_;
@ -23,12 +23,12 @@ namespace bayesnet {
model.fit(TAN::Xv, TAN::yv, features, className); model.fit(TAN::Xv, TAN::yv, features, className);
return *this; return *this;
} }
Tensor TANNew::predict(Tensor& X) Tensor TANLd::predict(Tensor& X)
{ {
auto Xt = prepareX(X); auto Xt = prepareX(X);
return TAN::predict(Xt); return TAN::predict(Xt);
} }
vector<string> TANNew::graph(const string& name) vector<string> TANLd::graph(const string& name)
{ {
return TAN::graph(name); return TAN::graph(name);
} }

19
src/BayesNet/TANLd.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef TANLD_H
#define TANLD_H
#include "TAN.h"
#include "Proposal.h"
namespace bayesnet {
using namespace std;
class TANLd : public TAN, public Proposal {
private:
public:
TANLd();
virtual ~TANLd() = default;
TANLd& fit(torch::Tensor& X, torch::Tensor& y, vector<string>& features, string className, map<string, vector<int>>& states) override;
vector<string> graph(const string& name = "TAN") override;
Tensor predict(Tensor& X) override;
static inline string version() { return "0.0.1"; };
};
}
#endif // !TANLD_H

View File

@ -1,19 +0,0 @@
#ifndef TANNEW_H
#define TANNEW_H
#include "TAN.h"
#include "Proposal.h"
namespace bayesnet {
using namespace std;
class TANNew : public TAN, public Proposal {
private:
public:
TANNew();
virtual ~TANNew() = default;
TANNew& fit(torch::Tensor& X, torch::Tensor& y, vector<string>& features, string className, map<string, vector<int>>& states) override;
vector<string> graph(const string& name = "TAN") override;
Tensor predict(Tensor& X) override;
static inline string version() { return "0.0.1"; };
};
}
#endif // !TANNEW_H

View File

@ -6,9 +6,9 @@
#include "TAN.h" #include "TAN.h"
#include "KDB.h" #include "KDB.h"
#include "SPODE.h" #include "SPODE.h"
#include "TANNew.h" #include "TANLd.h"
#include "KDBNew.h" #include "KDBLd.h"
#include "SPODENew.h" #include "SPODELd.h"
namespace platform { namespace platform {
class Models { class Models {
private: private:

View File

@ -2,16 +2,16 @@
#define MODEL_REGISTER_H #define MODEL_REGISTER_H
static platform::Registrar registrarT("TAN", static platform::Registrar registrarT("TAN",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::TAN();}); [](void) -> bayesnet::BaseClassifier* { return new bayesnet::TAN();});
static platform::Registrar registrarTN("TANNew", static platform::Registrar registrarTN("TANLd",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::TANNew();}); [](void) -> bayesnet::BaseClassifier* { return new bayesnet::TANLd();});
static platform::Registrar registrarS("SPODE", static platform::Registrar registrarS("SPODE",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::SPODE(2);}); [](void) -> bayesnet::BaseClassifier* { return new bayesnet::SPODE(2);});
static platform::Registrar registrarSN("SPODENew", static platform::Registrar registrarSN("SPODELd",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::SPODENew(2);}); [](void) -> bayesnet::BaseClassifier* { return new bayesnet::SPODELd(2);});
static platform::Registrar registrarK("KDB", static platform::Registrar registrarK("KDB",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::KDB(2);}); [](void) -> bayesnet::BaseClassifier* { return new bayesnet::KDB(2);});
static platform::Registrar registrarKN("KDBNew", static platform::Registrar registrarKN("KDBLd",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::KDBNew(2);}); [](void) -> bayesnet::BaseClassifier* { return new bayesnet::KDBLd(2);});
static platform::Registrar registrarA("AODE", static platform::Registrar registrarA("AODE",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::AODE();}); [](void) -> bayesnet::BaseClassifier* { return new bayesnet::AODE();});
#endif #endif