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
machine
KernelMachine.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) 1999-2009 Soeren Sonnenburg
8
* Written (W) 2011-2012 Heiko Strathmann
9
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10
*/
11
12
#ifndef _KERNEL_MACHINE_H__
13
#define _KERNEL_MACHINE_H__
14
15
#include <
shogun/lib/common.h
>
16
#include <
shogun/io/SGIO.h
>
17
#include <
shogun/kernel/Kernel.h
>
18
#include <
shogun/kernel/CustomKernel.h
>
19
#include <
shogun/labels/Labels.h
>
20
#include <
shogun/machine/Machine.h
>
21
22
#include <stdio.h>
23
24
namespace
shogun
25
{
26
class
CMachine;
27
class
CLabels;
28
class
CKernel;
29
50
class
CKernelMachine
:
public
CMachine
51
{
52
public
:
54
CKernelMachine
();
55
64
CKernelMachine
(
CKernel
* k,
const
SGVector<float64_t>
alphas,
const
SGVector<int32_t>
svs,
float64_t
b);
65
69
CKernelMachine
(
CKernelMachine
* machine);
70
72
virtual
~CKernelMachine
();
73
79
virtual
const
char
*
get_name
()
const
{
return
"KernelMachine"
; }
80
85
void
set_kernel
(
CKernel
* k);
86
91
CKernel
*
get_kernel
();
92
97
void
set_batch_computation_enabled
(
bool
enable);
98
103
bool
get_batch_computation_enabled
();
104
109
void
set_linadd_enabled
(
bool
enable);
110
115
bool
get_linadd_enabled
();
116
121
void
set_bias_enabled
(
bool
enable_bias);
122
127
bool
get_bias_enabled
();
128
133
float64_t
get_bias
();
134
139
void
set_bias
(
float64_t
bias);
140
146
int32_t
get_support_vector
(int32_t idx);
147
153
float64_t
get_alpha
(int32_t idx);
154
161
bool
set_support_vector
(int32_t idx, int32_t val);
162
169
bool
set_alpha
(int32_t idx,
float64_t
val);
170
175
int32_t
get_num_support_vectors
();
176
181
void
set_alphas
(
SGVector<float64_t>
alphas);
182
187
void
set_support_vectors
(
SGVector<int32_t>
svs);
188
190
SGVector<int32_t>
get_support_vectors
();
191
193
SGVector<float64_t>
get_alphas
();
194
199
bool
create_new_model
(int32_t num);
200
205
bool
init_kernel_optimization
();
206
213
virtual
CRegressionLabels
*
apply_regression
(
CFeatures
* data=NULL);
214
221
virtual
CBinaryLabels
*
apply_binary
(
CFeatures
* data=NULL);
222
228
virtual
float64_t
apply_one
(int32_t num);
229
235
static
void
*
apply_helper
(
void
* p);
236
243
virtual
bool
train_locked
(
SGVector<index_t>
indices);
244
251
virtual
CBinaryLabels
*
apply_locked_binary
(
SGVector<index_t>
indices);
252
259
virtual
CRegressionLabels
*
apply_locked_regression
(
260
SGVector<index_t>
indices);
261
268
virtual
SGVector<float64_t>
apply_locked_get_output
(
269
SGVector<index_t>
indices);
270
279
virtual
void
data_lock
(
CLabels
* labs,
CFeatures
* features=NULL);
280
282
virtual
void
data_unlock
();
283
285
virtual
bool
supports_locking
()
const
{
return
true
; }
286
288
virtual
CMachine
*
clone
()
289
{
290
return
new
CKernelMachine
(
this
);
291
}
292
293
protected
:
294
300
SGVector<float64_t>
apply_get_outputs
(
CFeatures
* data);
301
308
virtual
void
store_model_features
();
309
310
private
:
312
void
init();
313
314
protected
:
316
CKernel
*
kernel
;
317
319
CCustomKernel
*
m_custom_kernel
;
320
322
CKernel
*
m_kernel_backup
;
323
325
bool
use_batch_computation
;
326
328
bool
use_linadd
;
329
331
bool
use_bias
;
332
334
float64_t
m_bias
;
335
337
SGVector<float64_t>
m_alpha
;
338
340
SGVector<int32_t>
m_svs
;
341
};
342
}
343
#endif
/* _KERNEL_MACHINE_H__ */
SHOGUN
Machine Learning Toolbox - Documentation