2023-01-24 18:57:18 +01:00
|
|
|
|
|
|
|
#ifndef MLPP_MULTINOMIAL_NB_H
|
|
|
|
#define MLPP_MULTINOMIAL_NB_H
|
|
|
|
|
2023-01-23 21:13:26 +01:00
|
|
|
//
|
|
|
|
// MultinomialNB.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:20:18 +01:00
|
|
|
|
2023-01-25 00:54:50 +01:00
|
|
|
class MLPPMultinomialNB {
|
2023-01-24 19:00:54 +01:00
|
|
|
public:
|
2023-01-27 13:01:16 +01:00
|
|
|
MLPPMultinomialNB(std::vector<std::vector<real_t>> inputSet, std::vector<real_t> outputSet, int class_num);
|
|
|
|
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 computeTheta();
|
|
|
|
void Evaluate();
|
|
|
|
|
|
|
|
// Model Params
|
2023-01-27 13:01:16 +01:00
|
|
|
std::vector<real_t> priors;
|
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:00:54 +01:00
|
|
|
#endif /* MultinomialNB_hpp */
|