mirror of
https://github.com/Doctorado-ML/bayesclass.git
synced 2025-08-15 23:55: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)
|
||||
{
|
||||
|
||||
dataset = torch::cat({ X, y.view({150, 1}) }, 1);
|
||||
dataset = torch::cat({ X, y.view({y.size(0), 1}) }, 1);
|
||||
this->features = features;
|
||||
this->className = className;
|
||||
this->states = states;
|
||||
@@ -86,8 +86,8 @@ namespace bayesnet {
|
||||
Tensor y_pred = predict(X);
|
||||
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);
|
||||
Tensor predict(Tensor& X);
|
||||
float score(Tensor& X, Tensor& y);
|
||||
void show();
|
||||
vector<string> show();
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -10,9 +10,9 @@ namespace bayesnet {
|
||||
float theta;
|
||||
void add_m_edges(int idx, vector<int>& S, Tensor& weights);
|
||||
protected:
|
||||
void train();
|
||||
void train() override;
|
||||
public:
|
||||
KDB(int k, float theta=0.03);
|
||||
KDB(int k, float theta = 0.03);
|
||||
};
|
||||
}
|
||||
#endif
|
@@ -245,16 +245,18 @@ namespace bayesnet {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
void Network::show()
|
||||
vector<string> Network::show()
|
||||
{
|
||||
vector<string> result;
|
||||
// Draw the network
|
||||
for (auto node : nodes) {
|
||||
cout << node.first << " -> ";
|
||||
string line = node.first + " -> ";
|
||||
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();
|
||||
vector<vector<double>> predict_proba(const vector<vector<int>>&);
|
||||
double score(const vector<vector<int>>&, const vector<int>&);
|
||||
void show();
|
||||
vector<string> show();
|
||||
inline string version() { return "0.1.0"; }
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user