⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stump.h

📁 C++编写的机器学习算法 Lemga is a C++ package which consists of classes for several learning models and gener
💻 H
字号:
// -*- C++ -*-#ifndef __LEMGA_STUMP_H__#define __LEMGA_STUMP_H__/** @file *  @brief @link lemga::Stump Decision stump@endlink class. * *  $Id: stump.h 2542 2006-01-10 07:24:14Z ling $ */#include "learnmodel.h"namespace lemga {/** @brief Decision stump. *  @todo Documentation */class Stump : public LearnModel {    UINT idx;    REAL bd1, bd2;///< threshold is (bd1+bd2)/2    bool dir;     ///< \c true: sgn(x[idx] - th); \c false: -sgn(x[idx] - th).    bool hard;    ///< use the hard threshold?public:    explicit Stump (UINT n_in = 0)        : LearnModel(n_in, 1), idx(0), bd1(0), bd2(0), hard(true) {}    explicit Stump (std::istream& is) { is >> *this; }    virtual const id_t& id () const;    virtual Stump* create () const { return new Stump(); }    virtual Stump* clone () const { return new Stump(*this); }    UINT index () const { return idx; }    REAL threshold () const { return (bd1+bd2)/2; }    bool direction () const { return dir; }    bool soft_threshold () const { return !hard; }    void use_soft_threshold (bool s = true) { hard = !s; }    virtual bool support_weighted_data () const { return true; }    virtual REAL train ();    /// Find the optimal threshold and direction (prefer the middle thresholds)    static REAL train_1d (const std::vector<REAL>&, const std::vector<REAL>&,                          REAL, bool&, bool&, REAL&, REAL&);    /// Find the optimal threshold for positive direction    static REAL train_1d (const std::vector<REAL>&, const std::vector<REAL>&);    virtual Output operator() (const Input&) const;protected:    virtual bool serialize (std::ostream&, ver_list&) const;    virtual bool unserialize (std::istream&, ver_list&,                              const id_t& = empty_id);};} // namespace lemga#ifdef  __STUMP_H__#warning "This header file may conflict with another `stump.h' file."#endif#define __STUMP_H__#endif

⌨️ 快捷键说明

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