svm.h

来自「C++编写的机器学习算法 Lemga is a C++ package whi」· C头文件 代码 · 共 71 行

H
71
字号
// -*- C++ -*-#ifndef __LEMGA_SVM_H__#define __LEMGA_SVM_H__/** @file *  @brief A LEMGA interface to LIBSVM. * *  $Id: svm.h 2538 2006-01-08 10:01:17Z ling $ */#include "learnmodel.h"#include "kernel.h"namespace lemga {/// Hide LIBSVM details so other files don't need to include LIBSVM header.struct SVM_detail;const kernel::RBF _svm_ker(0.5);class SVM : public LearnModel {private:    SVM_detail *detail;    const kernel::Kernel& ker;public:    explicit SVM (const kernel::Kernel& = _svm_ker, UINT n_in = 0);    SVM (const SVM&);    explicit SVM (std::istream& is): ker(_svm_ker) { is >> *this; }    virtual ~SVM ();    const SVM& operator= (const SVM&);    virtual const id_t& id () const;    virtual SVM* create () const { return new SVM(); }    virtual SVM* clone () const { return new SVM(*this); }    REAL C () const;    void set_C (REAL);    UINT n_support_vectors () const;    Input support_vector (UINT) const;    /// @return @f$y_i\alpha_i@f$    REAL support_vector_coef (UINT) const;    REAL bias () const;    REAL kernel (const Input&, const Input&) const;    virtual bool support_weighted_data () const { return true; }    virtual void initialize ();    virtual REAL train ();    virtual Output operator() (const Input&) const;    virtual REAL margin_norm () const { return w_norm(); }    virtual REAL margin_of (const Input&, const Output&) const;    REAL w_norm () const;protected:    /// Gives the signed belief for 2-class problems    /// (positive belief means the larger label)    REAL signed_margin (const Input&) const;    virtual bool serialize (std::ostream&, ver_list&) const;    virtual bool unserialize (std::istream&, ver_list&,                              const id_t& = empty_id);};} // namespace lemga#ifdef  __SVM_H__#warning "This header file may conflict with another `svm.h' file."#endif#define __SVM_H__#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?