SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
classifier
svm
MPDSVM.h
浏览该文件的文档.
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
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#ifndef _MPDSVM_H___
12
#define _MPDSVM_H___
13
#include <
shogun/lib/common.h
>
14
#include <
shogun/classifier/svm/SVM.h
>
15
#include <
shogun/lib/Cache.h
>
16
#include <
shogun/labels/BinaryLabels.h
>
17
18
namespace
shogun
19
{
21
class
CMPDSVM
:
public
CSVM
22
{
23
public
:
25
CMPDSVM
();
26
33
CMPDSVM
(
float64_t
C,
CKernel
* k,
CLabels
* lab);
34
virtual
~CMPDSVM
();
35
40
virtual
EMachineType
get_classifier_type
() {
return
CT_MPD
; }
41
43
virtual
const
char
*
get_name
()
const
{
return
"MPDSVM"
; }
44
45
protected
:
54
virtual
bool
train_machine
(
CFeatures
* data=NULL);
55
62
inline
float64_t
compute_H
(int32_t i, int32_t j)
63
{
64
return
((
CBinaryLabels
*)
m_labels
)->get_label(i)*
65
((
CBinaryLabels
*)
m_labels
)->get_label(j)*
kernel
->
kernel
(i,j);
66
}
67
73
inline
KERNELCACHE_ELEM
*
lock_kernel_row
(int32_t i)
74
{
75
KERNELCACHE_ELEM
* line=NULL;
76
77
if
(
kernel_cache
->
is_cached
(i))
78
{
79
line=
kernel_cache
->
lock_entry
(i);
80
ASSERT
(line)
81
}
82
83
if
(!line)
84
{
85
line=
kernel_cache
->
set_entry
(i);
86
ASSERT
(line)
87
88
for
(int32_t j=0; j<
m_labels
->
get_num_labels
(); j++)
89
line[j]=(
KERNELCACHE_ELEM
) ((
CBinaryLabels
*)
m_labels
)->get_label(i)*((
CBinaryLabels
*) m_labels)->get_label(j)*
kernel
->
kernel
(i,j);
90
}
91
92
return
line;
93
}
94
99
inline
void
unlock_kernel_row
(int32_t i)
100
{
101
kernel_cache
->
unlock_entry
(i);
102
}
103
105
CCache<KERNELCACHE_ELEM>
*
kernel_cache
;
106
};
107
}
108
#endif
/* _MPDSVM_H___ */
SHOGUN
机器学习工具包 - 项目文档