SHOGUN
v3.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
classifier
svm
NewtonSVM.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 Harshit Syal
8
* Copyright (C) 2012 Harshit Syal
9
*/
10
11
#ifndef _NEWTONSVM_H___
12
#define _NEWTONSVM_H___
13
14
#include <
shogun/lib/common.h
>
15
#include <
shogun/machine/LinearMachine.h
>
16
#include <
shogun/features/DotFeatures.h
>
17
#include <
shogun/labels/Labels.h
>
18
19
namespace
shogun
20
{
21
#ifdef HAVE_LAPACK
22
27
class
CNewtonSVM
:
public
CLinearMachine
28
{
29
public
:
30
MACHINE_PROBLEM_TYPE
(
PT_BINARY
);
31
33
CNewtonSVM
();
34
41
CNewtonSVM
(
float64_t
C
,
CDotFeatures
* traindat,
CLabels
* trainlab, int32_t itr=20);
42
43
virtual
~CNewtonSVM
();
44
49
virtual
EMachineType
get_classifier_type
() {
return
CT_NEWTONSVM
; }
50
55
inline
void
set_C
(
float64_t
c) { C=c; }
56
60
inline
float64_t
get_epsilon
() {
return
epsilon
; }
61
66
inline
void
set_epsilon
(
float64_t
e) {
epsilon
=e; }
67
71
inline
float64_t
get_C
() {
return
C
; }
72
73
77
inline
void
set_bias_enabled
(
bool
enable_bias) {
use_bias
=enable_bias; }
78
82
inline
bool
get_bias_enabled
() {
return
use_bias
; }
83
87
inline
int32_t
get_num_iter
() {
return
num_iter
;}
88
92
inline
void
set_num_iter
(int32_t iter) {
num_iter
=iter; }
93
95
virtual
const
char
*
get_name
()
const
{
return
"NewtonSVM"
; }
96
97
protected
:
106
virtual
bool
train_machine
(
CFeatures
* data=NULL);
107
108
private
:
109
void
obj_fun_linear(
float64_t
* weights,
float64_t
* out,
float64_t
* obj,
110
int32_t* sv, int32_t* numsv,
float64_t
* grad);
111
112
void
line_search_linear(
float64_t
* weights,
float64_t
* d,
113
float64_t
* out,
float64_t
* tx);
114
115
protected
:
117
float64_t
lambda
,
C
,
epsilon
;
118
float64_t
prec
;
119
int32_t
x_n
,
x_d
,
num_iter
;
120
122
bool
use_bias
;
123
};
124
#endif //HAVE_LAPACK
125
}
126
#endif //_NEWTONSVM_H___
SHOGUN
Machine Learning Toolbox - Documentation