mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-11-14 14:07:18 +01:00
40 lines
779 B
C++
40 lines
779 B
C++
|
|
#ifndef MLPP_BERNOULLI_NB_H
|
|
#define MLPP_BERNOULLI_NB_H
|
|
|
|
//
|
|
// BernoulliNB.hpp
|
|
//
|
|
// Created by Marc Melikyan on 1/17/21.
|
|
//
|
|
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
class BernoulliNB {
|
|
public:
|
|
BernoulliNB(std::vector<std::vector<double>> inputSet, std::vector<double> outputSet);
|
|
std::vector<double> modelSetTest(std::vector<std::vector<double>> X);
|
|
double modelTest(std::vector<double> x);
|
|
double score();
|
|
|
|
private:
|
|
void computeVocab();
|
|
void computeTheta();
|
|
void Evaluate();
|
|
|
|
// Model Params
|
|
double prior_1 = 0;
|
|
double prior_0 = 0;
|
|
|
|
std::vector<std::map<double, int>> theta;
|
|
std::vector<double> vocab;
|
|
int class_num;
|
|
|
|
// Datasets
|
|
std::vector<std::vector<double>> inputSet;
|
|
std::vector<double> outputSet;
|
|
std::vector<double> y_hat;
|
|
};
|
|
|
|
#endif /* BernoulliNB_hpp */ |