OpenCV  2.4.13
Open Source Computer Vision
CvSVM Class Reference

#include <ml.hpp>

Inheritance diagram for CvSVM:
CvStatModel cv::ocl::CvSVM_OCL

Public Types

enum  {
  C_SVC =100, NU_SVC =101, ONE_CLASS =102, EPS_SVR =103,
  NU_SVR =104
}
 
enum  { LINEAR =0, POLY =1, RBF =2, SIGMOID =3 }
 
enum  {
  C =0, GAMMA =1, P =2, NU =3,
  COEF =4, DEGREE =5
}
 

Public Member Functions

 CvSVM ()
 
virtual ~CvSVM ()
 
 CvSVM (const CvMat *trainData, const CvMat *responses, const CvMat *varIdx=0, const CvMat *sampleIdx=0, CvSVMParams params=CvSVMParams())
 
virtual bool train (const CvMat *trainData, const CvMat *responses, const CvMat *varIdx=0, const CvMat *sampleIdx=0, CvSVMParams params=CvSVMParams())
 
virtual bool train_auto (const CvMat *trainData, const CvMat *responses, const CvMat *varIdx, const CvMat *sampleIdx, CvSVMParams params, int kfold=10, CvParamGrid Cgrid=get_default_grid(CvSVM::C), CvParamGrid gammaGrid=get_default_grid(CvSVM::GAMMA), CvParamGrid pGrid=get_default_grid(CvSVM::P), CvParamGrid nuGrid=get_default_grid(CvSVM::NU), CvParamGrid coeffGrid=get_default_grid(CvSVM::COEF), CvParamGrid degreeGrid=get_default_grid(CvSVM::DEGREE), bool balanced=false)
 
virtual float predict (const CvMat *sample, bool returnDFVal=false) const
 
virtual float predict (const CvMat *samples, CV_OUT CvMat *results) const
 
 CvSVM (const cv::Mat &trainData, const cv::Mat &responses, const cv::Mat &varIdx=cv::Mat(), const cv::Mat &sampleIdx=cv::Mat(), CvSVMParams params=CvSVMParams())
 
virtual bool train (const cv::Mat &trainData, const cv::Mat &responses, const cv::Mat &varIdx=cv::Mat(), const cv::Mat &sampleIdx=cv::Mat(), CvSVMParams params=CvSVMParams())
 
virtual bool train_auto (const cv::Mat &trainData, const cv::Mat &responses, const cv::Mat &varIdx, const cv::Mat &sampleIdx, CvSVMParams params, int k_fold=10, CvParamGrid Cgrid=CvSVM::get_default_grid(CvSVM::C), CvParamGrid gammaGrid=CvSVM::get_default_grid(CvSVM::GAMMA), CvParamGrid pGrid=CvSVM::get_default_grid(CvSVM::P), CvParamGrid nuGrid=CvSVM::get_default_grid(CvSVM::NU), CvParamGrid coeffGrid=CvSVM::get_default_grid(CvSVM::COEF), CvParamGrid degreeGrid=CvSVM::get_default_grid(CvSVM::DEGREE), bool balanced=false)
 
virtual float predict (const cv::Mat &sample, bool returnDFVal=false) const
 
void predict (cv::InputArray samples, cv::OutputArray results) const
 
virtual int get_support_vector_count () const
 
virtual const float * get_support_vector (int i) const
 
virtual CvSVMParams get_params () const
 
virtual void clear ()
 
virtual void write (CvFileStorage *storage, const char *name) const
 
virtual void read (CvFileStorage *storage, CvFileNode *node)
 
int get_var_count () const
 
- Public Member Functions inherited from CvStatModel
 CvStatModel ()
 
virtual ~CvStatModel ()
 
virtual void save (const char *filename, const char *name=0) const
 
virtual void load (const char *filename, const char *name=0)
 

Static Public Member Functions

static CvParamGrid get_default_grid (int param_id)
 

Protected Member Functions

virtual bool set_params (const CvSVMParams &params)
 
virtual bool train1 (int sample_count, int var_count, const float **samples, const void *responses, double Cp, double Cn, CvMemStorage *_storage, double *alpha, double &rho)
 
virtual bool do_train (int svm_type, int sample_count, int var_count, const float **samples, const CvMat *responses, CvMemStorage *_storage, double *alpha)
 
virtual void create_kernel ()
 
virtual void create_solver ()
 
virtual float predict (const float *row_sample, int row_len, bool returnDFVal=false) const
 
virtual void write_params (CvFileStorage *fs) const
 
virtual void read_params (CvFileStorage *fs, CvFileNode *node)
 
void optimize_linear_svm ()
 

Protected Attributes

CvSVMParams params
 
CvMatclass_labels
 
int var_all
 
float ** sv
 
int sv_total
 
CvMatvar_idx
 
CvMatclass_weights
 
CvSVMDecisionFuncdecision_func
 
CvMemStoragestorage
 
CvSVMSolversolver
 
CvSVMKernelkernel
 
- Protected Attributes inherited from CvStatModel
const char * default_model_name
 

Member Enumeration Documentation

anonymous enum
Enumerator
C_SVC 
NU_SVC 
ONE_CLASS 
EPS_SVR 
NU_SVR 
anonymous enum
Enumerator
LINEAR 
POLY 
RBF 
SIGMOID 
anonymous enum
Enumerator
GAMMA 
NU 
COEF 
DEGREE 

Constructor & Destructor Documentation

CvSVM::CvSVM ( )
virtual CvSVM::~CvSVM ( )
virtual
CvSVM::CvSVM ( const CvMat trainData,
const CvMat responses,
const CvMat varIdx = 0,
const CvMat sampleIdx = 0,
CvSVMParams  params = CvSVMParams() 
)
CvSVM::CvSVM ( const cv::Mat trainData,
const cv::Mat responses,
const cv::Mat varIdx = cv::Mat(),
const cv::Mat sampleIdx = cv::Mat(),
CvSVMParams  params = CvSVMParams() 
)

Member Function Documentation

virtual void CvSVM::clear ( )
virtual

Reimplemented from CvStatModel.

virtual void CvSVM::create_kernel ( )
protectedvirtual

Reimplemented in cv::ocl::CvSVM_OCL.

virtual void CvSVM::create_solver ( )
protectedvirtual

Reimplemented in cv::ocl::CvSVM_OCL.

virtual bool CvSVM::do_train ( int  svm_type,
int  sample_count,
int  var_count,
const float **  samples,
const CvMat responses,
CvMemStorage _storage,
double *  alpha 
)
protectedvirtual
static CvParamGrid CvSVM::get_default_grid ( int  param_id)
static
virtual CvSVMParams CvSVM::get_params ( ) const
inlinevirtual
virtual const float* CvSVM::get_support_vector ( int  i) const
virtual
virtual int CvSVM::get_support_vector_count ( ) const
virtual
int CvSVM::get_var_count ( ) const
inline
void CvSVM::optimize_linear_svm ( )
protected
virtual float CvSVM::predict ( const CvMat sample,
bool  returnDFVal = false 
) const
virtual
virtual float CvSVM::predict ( const CvMat samples,
CV_OUT CvMat results 
) const
virtual

Reimplemented in cv::ocl::CvSVM_OCL.

virtual float CvSVM::predict ( const cv::Mat sample,
bool  returnDFVal = false 
) const
virtual

Reimplemented in cv::ocl::CvSVM_OCL.

void CvSVM::predict ( cv::InputArray  samples,
cv::OutputArray  results 
) const
virtual float CvSVM::predict ( const float *  row_sample,
int  row_len,
bool  returnDFVal = false 
) const
protectedvirtual
virtual void CvSVM::read ( CvFileStorage storage,
CvFileNode node 
)
virtual

Reimplemented from CvStatModel.

virtual void CvSVM::read_params ( CvFileStorage fs,
CvFileNode node 
)
protectedvirtual
virtual bool CvSVM::set_params ( const CvSVMParams params)
protectedvirtual
virtual bool CvSVM::train ( const CvMat trainData,
const CvMat responses,
const CvMat varIdx = 0,
const CvMat sampleIdx = 0,
CvSVMParams  params = CvSVMParams() 
)
virtual
virtual bool CvSVM::train ( const cv::Mat trainData,
const cv::Mat responses,
const cv::Mat varIdx = cv::Mat(),
const cv::Mat sampleIdx = cv::Mat(),
CvSVMParams  params = CvSVMParams() 
)
virtual
virtual bool CvSVM::train1 ( int  sample_count,
int  var_count,
const float **  samples,
const void responses,
double  Cp,
double  Cn,
CvMemStorage _storage,
double *  alpha,
double &  rho 
)
protectedvirtual
virtual bool CvSVM::train_auto ( const CvMat trainData,
const CvMat responses,
const CvMat varIdx,
const CvMat sampleIdx,
CvSVMParams  params,
int  kfold = 10,
CvParamGrid  Cgrid = get_default_grid(CvSVM::C),
CvParamGrid  gammaGrid = get_default_grid(CvSVM::GAMMA),
CvParamGrid  pGrid = get_default_grid(CvSVM::P),
CvParamGrid  nuGrid = get_default_grid(CvSVM::NU),
CvParamGrid  coeffGrid = get_default_grid(CvSVM::COEF),
CvParamGrid  degreeGrid = get_default_grid(CvSVM::DEGREE),
bool  balanced = false 
)
virtual
virtual bool CvSVM::train_auto ( const cv::Mat trainData,
const cv::Mat responses,
const cv::Mat varIdx,
const cv::Mat sampleIdx,
CvSVMParams  params,
int  k_fold = 10,
CvParamGrid  Cgrid = CvSVM::get_default_grid(CvSVM::C),
CvParamGrid  gammaGrid = CvSVM::get_default_grid(CvSVM::GAMMA),
CvParamGrid  pGrid = CvSVM::get_default_grid(CvSVM::P),
CvParamGrid  nuGrid = CvSVM::get_default_grid(CvSVM::NU),
CvParamGrid  coeffGrid = CvSVM::get_default_grid(CvSVM::COEF),
CvParamGrid  degreeGrid = CvSVM::get_default_grid(CvSVM::DEGREE),
bool  balanced = false 
)
virtual
virtual void CvSVM::write ( CvFileStorage storage,
const char *  name 
) const
virtual

Reimplemented from CvStatModel.

virtual void CvSVM::write_params ( CvFileStorage fs) const
protectedvirtual

Member Data Documentation

CvMat* CvSVM::class_labels
protected
CvMat* CvSVM::class_weights
protected
CvSVMDecisionFunc* CvSVM::decision_func
protected
CvSVMKernel* CvSVM::kernel
protected
CvSVMParams CvSVM::params
protected
CvSVMSolver* CvSVM::solver
protected
CvMemStorage* CvSVM::storage
protected
float** CvSVM::sv
protected
int CvSVM::sv_total
protected
int CvSVM::var_all
protected
CvMat* CvSVM::var_idx
protected

The documentation for this class was generated from the following file: