-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
MulticlassLogisticRegression.h
113 lines (93 loc) · 2.3 KB
/
MulticlassLogisticRegression.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
/*
* 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.
*
* Written (W) 2012 Sergey Lisitsyn
* Copyright (C) 2012 Sergey Lisitsyn
*/
#ifndef MULTICLASSLOGISTICREGRESSION_H_
#define MULTICLASSLOGISTICREGRESSION_H_
#include <shogun/lib/config.h>
#include <shogun/lib/common.h>
#include <shogun/features/DotFeatures.h>
#include <shogun/machine/LinearMulticlassMachine.h>
namespace shogun
{
/** @brief multiclass logistic regression
*
*/
class CMulticlassLogisticRegression : public CLinearMulticlassMachine
{
public:
MACHINE_PROBLEM_TYPE(PT_MULTICLASS)
/** default constructor */
CMulticlassLogisticRegression();
/** standard constructor
* @param z z regularization constant value
* @param feats features
* @param labs labels
*/
CMulticlassLogisticRegression(float64_t z, CDotFeatures* feats, CLabels* labs);
/** destructor */
virtual ~CMulticlassLogisticRegression();
/** get name */
virtual const char* get_name() const
{
return "MulticlassLogisticRegression";
}
/** set z
* @param z z value
*/
inline void set_z(float64_t z)
{
ASSERT(z>0)
m_z = z;
}
/** get C
* @return C value
*/
inline float64_t get_z() const { return m_z; }
/** set epsilon
* @param epsilon epsilon value
*/
inline void set_epsilon(float64_t epsilon)
{
ASSERT(epsilon>0)
m_epsilon = epsilon;
}
/** get epsilon
* @return epsilon value
*/
inline float64_t get_epsilon() const { return m_epsilon; }
/** set max iter
* @param max_iter max iter value
*/
inline void set_max_iter(int32_t max_iter)
{
ASSERT(max_iter>0)
m_max_iter = max_iter;
}
/** get max iter
* @return max iter value
*/
inline int32_t get_max_iter() const { return m_max_iter; }
protected:
/** train machine */
virtual bool train_machine(CFeatures* data = NULL);
private:
/** init defaults */
void init_defaults();
/** register parameters */
void register_parameters();
protected:
/** regularization constant for each machine */
float64_t m_z;
/** tolerance */
float64_t m_epsilon;
/** max number of iterations */
int32_t m_max_iter;
};
}
#endif