mirror of
https://github.com/Doctorado-ML/bayesclass.git
synced 2025-08-16 16:15:57 +00:00
Fix some small mistakes
This commit is contained in:
@@ -8,7 +8,7 @@ namespace bayesnet {
|
|||||||
BaseClassifier& BaseClassifier::build(vector<string>& features, string className, map<string, vector<int>>& states)
|
BaseClassifier& BaseClassifier::build(vector<string>& features, string className, map<string, vector<int>>& states)
|
||||||
{
|
{
|
||||||
|
|
||||||
dataset = torch::cat({ X, y.view({150, 1}) }, 1);
|
dataset = torch::cat({ X, y.view({y.size(0), 1}) }, 1);
|
||||||
this->features = features;
|
this->features = features;
|
||||||
this->className = className;
|
this->className = className;
|
||||||
this->states = states;
|
this->states = states;
|
||||||
@@ -86,8 +86,8 @@ namespace bayesnet {
|
|||||||
Tensor y_pred = predict(X);
|
Tensor y_pred = predict(X);
|
||||||
return (y_pred == y).sum().item<float>() / y.size(0);
|
return (y_pred == y).sum().item<float>() / y.size(0);
|
||||||
}
|
}
|
||||||
void BaseClassifier::show()
|
vector<string> BaseClassifier::show()
|
||||||
{
|
{
|
||||||
model.show();
|
return model.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -28,9 +28,8 @@ namespace bayesnet {
|
|||||||
BaseClassifier& fit(vector<vector<int>>& X, vector<int>& y, vector<string>& features, string className, map<string, vector<int>>& states);
|
BaseClassifier& fit(vector<vector<int>>& X, vector<int>& y, vector<string>& features, string className, map<string, vector<int>>& states);
|
||||||
Tensor predict(Tensor& X);
|
Tensor predict(Tensor& X);
|
||||||
float score(Tensor& X, Tensor& y);
|
float score(Tensor& X, Tensor& y);
|
||||||
void show();
|
vector<string> show();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -10,9 +10,9 @@ namespace bayesnet {
|
|||||||
float theta;
|
float theta;
|
||||||
void add_m_edges(int idx, vector<int>& S, Tensor& weights);
|
void add_m_edges(int idx, vector<int>& S, Tensor& weights);
|
||||||
protected:
|
protected:
|
||||||
void train();
|
void train() override;
|
||||||
public:
|
public:
|
||||||
KDB(int k, float theta=0.03);
|
KDB(int k, float theta = 0.03);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@@ -245,16 +245,18 @@ namespace bayesnet {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
void Network::show()
|
vector<string> Network::show()
|
||||||
{
|
{
|
||||||
|
vector<string> result;
|
||||||
// Draw the network
|
// Draw the network
|
||||||
for (auto node : nodes) {
|
for (auto node : nodes) {
|
||||||
cout << node.first << " -> ";
|
string line = node.first + " -> ";
|
||||||
for (auto child : node.second->getChildren()) {
|
for (auto child : node.second->getChildren()) {
|
||||||
cout << child->getName() << ", ";
|
line += child->getName() + ", ";
|
||||||
}
|
}
|
||||||
cout << endl;
|
result.push_back(line);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ namespace bayesnet {
|
|||||||
torch::Tensor conditionalEdgeWeight();
|
torch::Tensor conditionalEdgeWeight();
|
||||||
vector<vector<double>> predict_proba(const vector<vector<int>>&);
|
vector<vector<double>> predict_proba(const vector<vector<int>>&);
|
||||||
double score(const vector<vector<int>>&, const vector<int>&);
|
double score(const vector<vector<int>>&, const vector<int>&);
|
||||||
void show();
|
vector<string> show();
|
||||||
inline string version() { return "0.1.0"; }
|
inline string version() { return "0.1.0"; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user