-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
/** Linear model class | ||
Author: Severin Gsponer ([email protected]) | ||
The model consist of is represented as vector of tupels from the step_size and the corresponding ngram | ||
The model consist of is represented as vector of tupels from the step_size | ||
and the corresponding ngram | ||
**/ | ||
|
||
#ifndef LINEARMODEL_H | ||
#define LINEARMODEL_H | ||
|
||
#include <vector> | ||
#include <tuple> | ||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <map> | ||
#include "unistd.h" | ||
#include <cstring> | ||
#include "common.h" | ||
#include "darts.h" | ||
#include <memory> | ||
#include "mmap.h" | ||
#include "unistd.h" | ||
#include <cmath> | ||
#include <cstring> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
#include <tuple> | ||
#include <vector> | ||
|
||
namespace LinearModel{ | ||
class LinearModel{ | ||
public: | ||
LinearModel():da(new Darts::DoubleArray){}; | ||
LinearModel(std::vector<std::tuple<double, std::string>> fullList):fullList(fullList){}; | ||
LinearModel(std::string filename, double threshold):da(new Darts::DoubleArray){ | ||
namespace LinearModel { | ||
class LinearModel { | ||
public: | ||
LinearModel() : da(new Darts::DoubleArray){}; | ||
LinearModel(std::vector<std::tuple<double, std::string>> fullList) : | ||
fullList(fullList){}; | ||
LinearModel(std::string filename, double threshold) : | ||
da(new Darts::DoubleArray) { | ||
open(filename, threshold); | ||
}; | ||
|
||
|
@@ -33,25 +37,25 @@ class LinearModel{ | |
void print_model(std::string outfile_name); | ||
void save_as_binary(std::string outfile_name); | ||
void build_tree(double multiplyValue = 1); | ||
friend bool operator== (const LinearModel &c1, const LinearModel &c2); | ||
friend bool operator==(const LinearModel &c1, const LinearModel &c2); | ||
std::shared_ptr<Darts::DoubleArray> da; | ||
|
||
bool open (std::string file, double threshold); | ||
bool open(std::string file, double threshold); | ||
double get_bias() const; | ||
void set_bias(double bias); | ||
std::vector <double> weights; | ||
std::vector<double> weights; | ||
void normalize_weights(); | ||
long double intercept = 0.0; | ||
private: | ||
double bias = 0.0; | ||
|
||
private: | ||
double bias = 0.0; | ||
double l1_norm = 0.0; | ||
double l2_norm = 0.0; | ||
std::vector <std::pair<const char *, double> > rules; | ||
std::vector<std::pair<const char *, double>> rules; | ||
std::vector<std::tuple<double, std::string>> fullList; | ||
|
||
}; | ||
|
||
std::vector<std::tuple<double, std::string>> parse_model(std::string file); | ||
}; | ||
std::vector<std::tuple<double, std::string>> parse_model(std::string file); | ||
}; // namespace LinearModel | ||
|
||
#endif |