2023-01-24 18:57:18 +01:00
|
|
|
|
|
|
|
#ifndef MLPP_BERNOULLI_NB_H
|
|
|
|
#define MLPP_BERNOULLI_NB_H
|
|
|
|
|
2023-01-23 21:13:26 +01:00
|
|
|
//
|
|
|
|
// BernoulliNB.hpp
|
|
|
|
//
|
|
|
|
// Created by Marc Melikyan on 1/17/21.
|
|
|
|
//
|
|
|
|
|
2023-01-27 13:01:16 +01:00
|
|
|
#include "core/math/math_defs.h"
|
|
|
|
|
2023-01-23 21:13:26 +01:00
|
|
|
#include <map>
|
2023-01-24 19:00:54 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2023-01-24 19:29:29 +01:00
|
|
|
class MLPPBernoulliNB {
|
2023-01-24 19:00:54 +01:00
|
|
|
public:
|
2023-01-27 13:01:16 +01:00
|
|
|
MLPPBernoulliNB(std::vector<std::vector<real_t>> inputSet, std::vector<real_t> outputSet);
|
|
|
|
std::vector<real_t> modelSetTest(std::vector<std::vector<real_t>> X);
|
|
|
|
real_t modelTest(std::vector<real_t> x);
|
|
|
|
real_t score();
|
2023-01-24 19:00:54 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void computeVocab();
|
|
|
|
void computeTheta();
|
|
|
|
void Evaluate();
|
|
|
|
|
|
|
|
// Model Params
|
2023-01-27 13:01:16 +01:00
|
|
|
real_t prior_1 = 0;
|
|
|
|
real_t prior_0 = 0;
|
2023-01-24 19:00:54 +01:00
|
|
|
|
2023-01-27 13:01:16 +01:00
|
|
|
std::vector<std::map<real_t, int>> theta;
|
|
|
|
std::vector<real_t> vocab;
|
2023-01-24 19:00:54 +01:00
|
|
|
int class_num;
|
|
|
|
|
|
|
|
// Datasets
|
2023-01-27 13:01:16 +01:00
|
|
|
std::vector<std::vector<real_t>> inputSet;
|
|
|
|
std::vector<real_t> outputSet;
|
|
|
|
std::vector<real_t> y_hat;
|
2023-01-24 19:00:54 +01:00
|
|
|
};
|
2023-01-23 21:13:26 +01:00
|
|
|
|
2023-01-24 19:20:18 +01:00
|
|
|
#endif /* BernoulliNB_hpp */
|