forked from BRAINSia/BRAINSStandAlone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogisticRegression.h
56 lines (48 loc) · 1.58 KB
/
LogisticRegression.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef LOGISTICREGRESSION_h
#define LOGISTICREGRESSION_h
#include "linear.h"
#include <vector>
#include <map>
template <typename TSampleType>
class LogisticRegressionSample {
private:
std::vector<TSampleType> *m_sample;
unsigned int m_label;
std::map<unsigned int, double> m_predictedProbability;
bool m_labelSet;
public:
LogisticRegressionSample(const unsigned int featureCount);
~LogisticRegressionSample();
double GetLabelProbability(unsigned int const &);
void SetSample(std::vector<TSampleType> &);
std::vector<TSampleType> const * GetSample() const;
void SetLabelProbability(unsigned int const &, double const &);
unsigned int GetLabel() const {return this->m_label;};
void SetLabel(unsigned int const &) ;
bool LabelIsSet() const {return this->m_labelSet;};
};
template <typename TSampleType>
class LogisticRegression {
private:
unsigned int m_sampleCount;
unsigned int m_totalSamples;
struct parameter m_parameters;
struct problem m_problem;
struct model * m_model;
struct feature_node * m_featureNodes;
unsigned int m_featureCount;
unsigned int m_classOneLabel;
unsigned int m_classTwoLabel;
bool m_classOneLabelSet;
bool m_classTwoLabelSet;
public:
LogisticRegression (const unsigned int featureCount, const unsigned int sampleCount);
~LogisticRegression ();
void AddLabeledSample(LogisticRegressionSample<TSampleType> const & );
void TrainModel();
void SetClassOneLabel(const unsigned int);
void SetClassTwoLabel(const unsigned int);
void ClassifySample(LogisticRegressionSample<TSampleType> &);
};
#include "LogisticRegression.hxx"
#endif