Loading...
Searching...
No Matches
libsvmModel.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
//
#ifndef LIBSVMMODELH
#define LIBSVMMODELH
#ifndef SVRMODEL
#include <BALL/QSAR/svrModel.h>
#endif
#include <fstream>
#include <svm.h>
namespace BALL
{
namespace QSAR
{
class BALL_EXPORT LibsvmModel : public SVRModel
{
public:
LibsvmModel(const QSARData& q, int k_type, double p1, double p2=-1);
virtual ~LibsvmModel();
void train();
//RowVector predict(const vector<double>& substance, bool transform=1);
void setParameters(vector<double>& v);
virtual vector<double> getParameters() const;
private:
// part of libsvm; unfortunately defined in svm.C instead of svm.h, so that we need this hack ...
struct svm_model
{
svm_parameter param; // parameter
int nr_class; // number of classes, = 2 in regression/one class svm
int l; // total #SV
svm_node **SV; // SVs (SV[l])
double **sv_coef; // coefficients for SVs in decision functions (sv_coef[k-1][l])
double *rho; // constants in decision functions (rho[k*(k-1)/2])
double *probA; // pariwise probability information
double *probB;
// for classification only
int *label; // label of each class (label[k])
int *nSV; // number of SVs for each class (nSV[k])
// nSV[0] + nSV[1] + ... + nSV[k-1] = l
// XXX
int free_sv; // 1 if svm_model is created by svm_load_model
// 0 if svm_model is created by svm_train
};
struct svm_problem* createProblem(int response_id);
void createParameters();
struct svm_model* svm_train_result_;
struct svm_parameter parameters_;
struct svm_node* x_space_;
bool use_nu_;
bool use_shrinking_;
double nu_;
double p_;
double eps_;
double C_;
};
}
}
#endif // LIBSVMMODELH
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::QSAR::LibsvmModel::getParameters
virtual vector< double > getParameters() const
BALL::QSAR::LibsvmModel::setParameters
void setParameters(vector< double > &v)
BALL::QSAR::LibsvmModel::LibsvmModel
LibsvmModel(const QSARData &q, int k_type, double p1, double p2=-1)
BALL::QSAR::LibsvmModel::train
void train()
BALL::QSAR::LibsvmModel::~LibsvmModel
virtual ~LibsvmModel()
BALL::QSAR::QSARData
Definition QSARData.h:56
BALL::QSAR::SVRModel::SVRModel
SVRModel(const QSARData &q, int k_type, double p1, double p2)
BALL::QSAR
Definition allModel.h:17
BALL
Definition constants.h:13
svrModel.h