Solved Ld poor results
This commit is contained in:
parent
3a85481a5a
commit
405887f833
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -25,12 +25,12 @@
|
||||
"program": "${workspaceFolder}/build/src/Platform/main",
|
||||
"args": [
|
||||
"-m",
|
||||
"TANLd",
|
||||
"SPODELd",
|
||||
"-p",
|
||||
"/Users/rmontanana/Code/discretizbench/datasets",
|
||||
"--stratified",
|
||||
"-d",
|
||||
"vehicle"
|
||||
"iris"
|
||||
],
|
||||
"cwd": "/Users/rmontanana/Code/discretizbench",
|
||||
},
|
||||
|
@ -12,7 +12,7 @@ namespace bayesnet {
|
||||
Xf = X_;
|
||||
y = y_;
|
||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||
fit_local_discretization(states, y);
|
||||
states = fit_local_discretization(y);
|
||||
// We have discretized the input data
|
||||
// 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
|
||||
Ensemble::fit(dataset, features, className, states);
|
||||
|
@ -11,7 +11,7 @@ namespace bayesnet {
|
||||
Xf = X_;
|
||||
y = y_;
|
||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||
fit_local_discretization(states, y);
|
||||
states = fit_local_discretization(y);
|
||||
// We have discretized the input data
|
||||
// 1st we need to fit the model to build the normal KDB structure, KDB::fit initializes the base Bayesian network
|
||||
KDB::fit(dataset, features, className, states);
|
||||
|
@ -67,10 +67,12 @@ namespace bayesnet {
|
||||
model.fit(pDataset, pFeatures, pClassName, states);
|
||||
}
|
||||
}
|
||||
void Proposal::fit_local_discretization(map<string, vector<int>>& states, torch::Tensor& y)
|
||||
map<string, vector<int>> Proposal::fit_local_discretization(torch::Tensor& y)
|
||||
{
|
||||
// Discretize the continuous input data and build pDataset (Classifier::dataset)
|
||||
int m = Xf.size(1);
|
||||
int n = Xf.size(0);
|
||||
map<string, vector<int>> states;
|
||||
pDataset = torch::zeros({ n + 1, m }, kInt32);
|
||||
auto yv = vector<int>(y.data_ptr<int>(), y.data_ptr<int>() + y.size(0));
|
||||
// discretize input data by feature(row)
|
||||
@ -89,6 +91,8 @@ namespace bayesnet {
|
||||
auto yStates = vector<int>(n_classes);
|
||||
iota(yStates.begin(), yStates.end(), 0);
|
||||
states[pClassName] = yStates;
|
||||
pDataset.index_put_({ n, "..." }, y);
|
||||
return states;
|
||||
}
|
||||
torch::Tensor Proposal::prepareX(torch::Tensor& X)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace bayesnet {
|
||||
protected:
|
||||
torch::Tensor prepareX(torch::Tensor& X);
|
||||
void localDiscretizationProposal(map<string, vector<int>>& states, Network& model);
|
||||
void fit_local_discretization(map<string, vector<int>>& states, torch::Tensor& y);
|
||||
map<string, vector<int>> fit_local_discretization(torch::Tensor& y);
|
||||
torch::Tensor Xf; // X continuous nxm tensor
|
||||
torch::Tensor y; // y discrete nx1 tensor
|
||||
map<string, mdlp::CPPFImdlp*> discretizers;
|
||||
|
@ -11,7 +11,7 @@ namespace bayesnet {
|
||||
Xf = X_;
|
||||
y = y_;
|
||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||
fit_local_discretization(states, y);
|
||||
states = fit_local_discretization(y);
|
||||
// We have discretized the input data
|
||||
// 1st we need to fit the model to build the normal SPODE structure, SPODE::fit initializes the base Bayesian network
|
||||
SPODE::fit(dataset, features, className, states);
|
||||
@ -27,7 +27,7 @@ namespace bayesnet {
|
||||
features = features_;
|
||||
className = className_;
|
||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||
fit_local_discretization(states, y);
|
||||
states = fit_local_discretization(y);
|
||||
// We have discretized the input data
|
||||
// 1st we need to fit the model to build the normal SPODE structure, SPODE::fit initializes the base Bayesian network
|
||||
SPODE::fit(dataset, features, className, states);
|
||||
|
@ -11,7 +11,7 @@ namespace bayesnet {
|
||||
Xf = X_;
|
||||
y = y_;
|
||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & y
|
||||
fit_local_discretization(states, y);
|
||||
states = fit_local_discretization(y);
|
||||
// We have discretized the input data
|
||||
// 1st we need to fit the model to build the normal TAN structure, TAN::fit initializes the base Bayesian network
|
||||
TAN::fit(dataset, features, className, states);
|
||||
|
Loading…
Reference in New Issue
Block a user