Begin Ensemble

This commit is contained in:
2023-07-14 18:23:24 +02:00
parent e8b8fa29c8
commit 6a8aad5911
5 changed files with 112 additions and 10 deletions

34
src/Ensemble.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef ENSEMBLE_H
#define ENSEMBLE_H
#include <torch/torch.h>
#include "BaseClassifier.h"
#include "Metrics.hpp"
using namespace std;
using namespace torch;
namespace bayesnet {
class Ensemble {
private:
Ensemble& build(vector<string>& features, string className, map<string, vector<int>>& states);
protected:
BaseClassifier& model;
vector<BaseClassifier> models;
int m, n; // m: number of samples, n: number of features
Tensor X;
Tensor y;
Tensor dataset;
Metrics metrics;
vector<string> features;
string className;
map<string, vector<int>> states;
void virtual train() = 0;
public:
Ensemble(BaseClassifier& model);
Ensemble& fit(Tensor& X, Tensor& y, vector<string>& features, string className, map<string, vector<int>>& states);
Ensemble& 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);
vector<string> show();
};
}
#endif