-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.hpp
38 lines (29 loc) · 1007 Bytes
/
model.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef MODEL_HPP
#define MODEL_HPP
#include <string>
#include <unordered_map>
#include <vector>
#include "sparse.hpp"
class Model {
private:
unsigned int k;
long double lambda;
// biases (not tuned)
long double mu;
std::vector<long double> muUsers;
std::vector<long double> muMovies;
// factors
std::vector<long double>* U;
std::vector<long double>* M;
// weights
std::vector<long double>* W;
// useful stuff
std::unordered_map<unsigned int, unsigned int> userIdxs;
SparseVector* R;
public:
void initialize(std::string dataPath, unsigned int numUsers, unsigned int numMovies, unsigned int k, long double lambda);
void train(std::string trainDataPath, std::string valDataPath, long double lr, long double decay, unsigned int epochs);
void predict(std::string dataPath);
void inference(std::string dataPath, std::string outDataPath);
};
#endif