/usr/include/shogun/classifier/svm/NewtonSVM.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 114 115 116 117 118 119 120 121 122 123 124 125 126 | /*
* 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 Harshit Syal
* Copyright (C) 2012 Harshit Syal
*/
#ifndef _NEWTONSVM_H___
#define _NEWTONSVM_H___
#include <shogun/lib/common.h>
#include <shogun/machine/LinearMachine.h>
#include <shogun/features/DotFeatures.h>
#include <shogun/labels/Labels.h>
namespace shogun
{
#ifdef HAVE_LAPACK
/** @brief NewtonSVM,
* In this Implementation linear SVM is trained in its primal form using Newton-like iterations.
* This Implementation is ported from the Olivier Chapelles fast newton based SVM solver, Which could be found here :http://mloss.org/software/view/30/
* For further information on this implementation of SVM refer to this paper: http://www.kyb.mpg.de/publications/attachments/neco_%5B0%5D.pdf
*/
class CNewtonSVM : public CLinearMachine
{
public:
MACHINE_PROBLEM_TYPE(PT_BINARY);
/** default constructor */
CNewtonSVM();
/** constructor
* @param C constant C
* @param itr constant no of iterations
* @param traindat training features
* @param trainlab labels for features
*/
CNewtonSVM(float64_t C, CDotFeatures* traindat, CLabels* trainlab, int32_t itr=20);
virtual ~CNewtonSVM();
/** get classifier type
*
* @return classifier type NewtonSVM
*/
virtual EMachineType get_classifier_type() { return CT_NEWTONSVM; }
/**
* set C
* @param C constant C
*/
inline void set_C(float64_t c) { C=c; }
/** get epsilon
* @return epsilon
*/
inline float64_t get_epsilon() { return epsilon; }
/**
* set epsilon
* @param epsilon constant epsilon
*/
inline void set_epsilon(float64_t e) { epsilon=e; }
/** get C
* @return C
*/
inline float64_t get_C() { return C; }
/** set if bias shall be enabled
* @param enable_bias if bias shall be enabled
*/
inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
/** get if bias is enabled
* @return if bias is enabled
*/
inline bool get_bias_enabled() { return use_bias; }
/** set num_iter
* @return num_iter
*/
inline int32_t get_num_iter() {return num_iter;}
/** set iter
* @param num_iter number of iterations
*/
inline void set_num_iter(int32_t iter) { num_iter=iter; }
/** @return object name */
virtual const char* get_name() const { return "NewtonSVM"; }
protected:
/** train SVM classifier
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train_machine(CFeatures* data=NULL);
private:
void obj_fun_linear(float64_t* weights, float64_t* out, float64_t* obj,
int32_t* sv, int32_t* numsv, float64_t* grad);
void line_search_linear(float64_t* weights, float64_t* d,
float64_t* out, float64_t* tx);
protected:
/** lambda=1/C */
float64_t lambda, C, epsilon;
float64_t prec;
int32_t x_n, x_d, num_iter;
/** if bias is used */
bool use_bias;
};
#endif //HAVE_LAPACK
}
#endif //_NEWTONSVM_H___
|