SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
multiclass
ecoc
ECOCRandomSparseEncoder.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 2012 Chiyuan Zhang
8
* Copyright (C) 2012 Chiyuan Zhang
9
*/
10
11
#ifndef ECOCRANDOMSPARSEENCODER_H__
12
#define ECOCRANDOMSPARSEENCODER_H__
13
14
#include <
shogun/mathematics/Math.h
>
15
#include <
shogun/multiclass/ecoc/ECOCEncoder.h
>
16
17
namespace
shogun
18
{
19
36
class
CECOCRandomSparseEncoder
:
public
CECOCEncoder
37
{
38
public
:
48
CECOCRandomSparseEncoder
(int32_t maxiter=10000, int32_t codelen=0,
49
float64_t
pzero=0.5,
float64_t
pposone=0.25,
float64_t
pnegone=0.25);
50
52
virtual
~CECOCRandomSparseEncoder
() {}
53
59
void
set_probability
(
float64_t
pzero,
float64_t
pposone,
float64_t
pnegone);
60
62
virtual
const
char
*
get_name
()
const
{
return
"ECOCRandomSparseEncoder"
; }
63
73
int32_t
get_default_code_length
(int32_t num_classes)
const
74
{
75
return
static_cast<
int32_t
>
(
CMath::round
(15 *
CMath::log
(num_classes)));
76
}
77
81
virtual
SGMatrix<int32_t>
create_codebook
(int32_t num_classes);
82
83
protected
:
85
int32_t
m_maxiter
;
87
int32_t
m_codelen
;
89
float64_t
m_pzero
;
91
float64_t
m_pposone
;
93
float64_t
m_pnegone
;
94
95
private
:
101
bool
check_probability(
float64_t
pzero,
float64_t
pposone,
float64_t
pnegone)
102
{
103
if
(
CMath::abs
(pzero + pposone + pnegone - 1) > 1e-5)
104
return
false
;
105
return
true
;
106
}
107
109
void
init();
110
};
111
112
}
/* shogun */
113
114
#endif
/* end of include guard: ECOCRANDOMSPARSEENCODER_H__ */
115
SHOGUN
Machine Learning Toolbox - Documentation