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",
|
"program": "${workspaceFolder}/build/src/Platform/main",
|
||||||
"args": [
|
"args": [
|
||||||
"-m",
|
"-m",
|
||||||
"TANLd",
|
"SPODELd",
|
||||||
"-p",
|
"-p",
|
||||||
"/Users/rmontanana/Code/discretizbench/datasets",
|
"/Users/rmontanana/Code/discretizbench/datasets",
|
||||||
"--stratified",
|
"--stratified",
|
||||||
"-d",
|
"-d",
|
||||||
"vehicle"
|
"iris"
|
||||||
],
|
],
|
||||||
"cwd": "/Users/rmontanana/Code/discretizbench",
|
"cwd": "/Users/rmontanana/Code/discretizbench",
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,7 @@ namespace bayesnet {
|
|||||||
Xf = X_;
|
Xf = X_;
|
||||||
y = y_;
|
y = y_;
|
||||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & 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
|
// 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
|
// 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);
|
Ensemble::fit(dataset, features, className, states);
|
||||||
|
@ -11,7 +11,7 @@ namespace bayesnet {
|
|||||||
Xf = X_;
|
Xf = X_;
|
||||||
y = y_;
|
y = y_;
|
||||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & 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
|
// 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
|
// 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);
|
KDB::fit(dataset, features, className, states);
|
||||||
|
@ -67,10 +67,12 @@ namespace bayesnet {
|
|||||||
model.fit(pDataset, pFeatures, pClassName, states);
|
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 m = Xf.size(1);
|
||||||
int n = Xf.size(0);
|
int n = Xf.size(0);
|
||||||
|
map<string, vector<int>> states;
|
||||||
pDataset = torch::zeros({ n + 1, m }, kInt32);
|
pDataset = torch::zeros({ n + 1, m }, kInt32);
|
||||||
auto yv = vector<int>(y.data_ptr<int>(), y.data_ptr<int>() + y.size(0));
|
auto yv = vector<int>(y.data_ptr<int>(), y.data_ptr<int>() + y.size(0));
|
||||||
// discretize input data by feature(row)
|
// discretize input data by feature(row)
|
||||||
@ -89,6 +91,8 @@ namespace bayesnet {
|
|||||||
auto yStates = vector<int>(n_classes);
|
auto yStates = vector<int>(n_classes);
|
||||||
iota(yStates.begin(), yStates.end(), 0);
|
iota(yStates.begin(), yStates.end(), 0);
|
||||||
states[pClassName] = yStates;
|
states[pClassName] = yStates;
|
||||||
|
pDataset.index_put_({ n, "..." }, y);
|
||||||
|
return states;
|
||||||
}
|
}
|
||||||
torch::Tensor Proposal::prepareX(torch::Tensor& X)
|
torch::Tensor Proposal::prepareX(torch::Tensor& X)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace bayesnet {
|
|||||||
protected:
|
protected:
|
||||||
torch::Tensor prepareX(torch::Tensor& X);
|
torch::Tensor prepareX(torch::Tensor& X);
|
||||||
void localDiscretizationProposal(map<string, vector<int>>& states, Network& model);
|
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 Xf; // X continuous nxm tensor
|
||||||
torch::Tensor y; // y discrete nx1 tensor
|
torch::Tensor y; // y discrete nx1 tensor
|
||||||
map<string, mdlp::CPPFImdlp*> discretizers;
|
map<string, mdlp::CPPFImdlp*> discretizers;
|
||||||
|
@ -11,7 +11,7 @@ namespace bayesnet {
|
|||||||
Xf = X_;
|
Xf = X_;
|
||||||
y = y_;
|
y = y_;
|
||||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & 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
|
// 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
|
// 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);
|
SPODE::fit(dataset, features, className, states);
|
||||||
@ -27,7 +27,7 @@ namespace bayesnet {
|
|||||||
features = features_;
|
features = features_;
|
||||||
className = className_;
|
className = className_;
|
||||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & 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
|
// 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
|
// 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);
|
SPODE::fit(dataset, features, className, states);
|
||||||
|
@ -11,7 +11,7 @@ namespace bayesnet {
|
|||||||
Xf = X_;
|
Xf = X_;
|
||||||
y = y_;
|
y = y_;
|
||||||
// Fills vectors Xv & yv with the data from tensors X_ (discretized) & 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
|
// 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
|
// 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);
|
TAN::fit(dataset, features, className, states);
|
||||||
|
Loading…
Reference in New Issue
Block a user