-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
SparseInverseCovariance.h
129 lines (108 loc) · 2.44 KB
/
SparseInverseCovariance.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012 Sergey Lisitsyn
*/
#ifndef SPINVCOV_H_
#define SPINVCOV_H_
#include <shogun/lib/config.h>
#ifdef USE_GPL_SHOGUN
#include <shogun/base/SGObject.h>
#include <shogun/lib/SGMatrix.h>
namespace shogun
{
/** @brief used to estimate inverse covariance matrix using graphical lasso
*
* implementation is based on SLEP library's code
*/
class CSparseInverseCovariance : public CSGObject
{
public:
/** constructor */
CSparseInverseCovariance();
/** destructor */
virtual ~CSparseInverseCovariance();
/** estimate inverse covariance matrix
*
* @param S empirical covariance matrix
* @param lambda_c regularization constant
*/
SGMatrix<float64_t> estimate(SGMatrix<float64_t> S, float64_t lambda_c);
/** get name */
const char* get_name() const { return "SparseInverseCovariance"; };
/** get lasso max iter
* @return lasso max iter
*/
int32_t get_lasso_max_iter() const { return m_lasso_max_iter; }
/** get max iter
* @return max iter
*/
int32_t get_max_iter() const { return m_max_iter; }
/** get lasso max iter
* @return lasso max iter
*/
float64_t get_f_gap() const { return m_f_gap; }
/** get lasso max iter
* @return lasso max iter
*/
float64_t get_x_gap() const { return m_x_gap; }
/** get lasso max iter
* @return lasso max iter
*/
float64_t get_xtol() const { return m_xtol; }
/** set lasso max iter
* @param lasso_max_iter lasso max iter
*/
void set_lasso_max_iter(int32_t lasso_max_iter)
{
m_lasso_max_iter = lasso_max_iter;
}
/** set max iter
* @param max_iter max iter
*/
void set_max_iter(int32_t max_iter)
{
m_max_iter = max_iter;
}
/** set f gap
* @param f_gap f gap
*/
void set_f_gap(int32_t f_gap)
{
m_f_gap = f_gap;
}
/** set x gap
* @param x_gap x gap
*/
void set_x_gap(int32_t x_gap)
{
m_x_gap = x_gap;
}
/** set xtol
* @param xtol xtol
*/
void set_xtol(int32_t xtol)
{
m_xtol = xtol;
}
private:
/** register parameters */
void register_parameters();
protected:
/** LASSO max iter */
int32_t m_lasso_max_iter;
/** max iter */
int32_t m_max_iter;
/** fGap */
float64_t m_f_gap;
/** xGap */
float64_t m_x_gap;
/** xtol */
float64_t m_xtol;
};
}
#endif //USE_GPL_SHOGUN
#endif