![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
00001 /* 00002 * The GURLS Package in C++ 00003 * 00004 * Copyright (C) 2011-1013, IIT@MIT Lab 00005 * All rights reserved. 00006 * 00007 * author: M. Santoro 00008 * email: msantoro@mit.edu 00009 * website: http://cbcl.mit.edu/IIT@MIT/IIT@MIT.html 00010 * 00011 * Redistribution and use in source and binary forms, with or without 00012 * modification, are permitted provided that the following conditions 00013 * are met: 00014 * 00015 * * Redistributions of source code must retain the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer. 00018 * * Redistributions in binary form must reproduce the above 00019 * copyright notice, this list of conditions and the following 00020 * disclaimer in the documentation and/or other materials 00021 * provided with the distribution. 00022 * * Neither the name(s) of the copyright holders nor the names 00023 * of its contributors or of the Massacusetts Institute of 00024 * Technology or of the Italian Institute of Technology may be 00025 * used to endorse or promote products derived from this software 00026 * without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00029 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00030 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00031 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00032 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00033 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00034 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00035 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00036 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00037 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00038 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00039 * POSSIBILITY OF SUCH DAMAGE. 00040 */ 00041 00042 #ifndef GURLS_WRAPPER_H 00043 #define GURLS_WRAPPER_H 00044 00045 #include "gurls++/gvec.h" 00046 #include "gurls++/gmat2d.h" 00047 #include "gurls++/optlist.h" 00048 00049 namespace gurls 00050 { 00051 00056 template<typename T> 00057 class GurlsWrapper 00058 { 00059 public: 00060 00061 enum ProblemType{CLASSIFICATION, REGRESSION}; 00062 00063 00069 GurlsWrapper(const std::string& name); 00070 00074 ~GurlsWrapper(); 00075 00082 virtual void train(const gMat2D<T> &X, const gMat2D<T> &y) = 0; 00083 00091 virtual T eval(const gVec<T> &X, unsigned long *index = NULL); 00092 00099 virtual gMat2D<T>* eval(const gMat2D<T> &X) = 0; 00100 00104 virtual const GurlsOptionsList& getOpt() const; 00105 00111 virtual void saveModel(const std::string &fileName); 00112 00118 virtual void loadModel(const std::string &fileName); 00119 00120 // virtual void exportModel(const std::string &fileName); 00121 // virtual void importModel(const std::string &fileName); 00122 00127 virtual void setNparams(unsigned long value); 00128 00133 virtual void setParam(double value); 00134 00139 virtual void setSplitProportion(double value); 00140 00145 virtual void setProblemType(ProblemType value); 00146 00147 // /** 00148 // * 00149 // * \param value 00150 // */ 00151 // virtual void setParameter(const std::string &key, GurlsOption* value); 00152 00153 // /** 00154 // * 00155 // * \param value 00156 // */ 00157 // virtual GurlsOption* getParameter(const std::string &key); 00158 00159 protected: 00163 virtual bool trainedModel(); 00164 00165 std::string name; 00166 GurlsOptionsList *opt; 00167 00168 ProblemType probType; 00169 00170 }; 00171 00176 template<typename T> 00177 class KernelWrapper : public GurlsWrapper<T> 00178 { 00179 public: 00180 enum KernelType{RBF, LINEAR/*, CHISQUARED*/}; 00181 00187 KernelWrapper(const std::string& name); 00188 00189 00196 virtual void train(const gMat2D<T> &X, const gMat2D<T> &y) = 0; 00197 00198 00203 virtual void setKernelType(KernelType value); 00204 00209 virtual void setSigma(double value); 00210 00215 virtual void setNSigma(unsigned long value); 00216 00217 00218 protected: 00219 KernelType kType; 00220 }; 00221 00222 } 00223 00224 #include"wrapper.hpp" 00225 00226 #endif //GURLS_WRAPPER_H