quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_pr.a #include <SupportVectorMachine.h> ALGORITHM getAlgorithm(); boolean setAlgorithm(ALGORITHM arg); IMPLEMENTATION getImplementation(); boolean setImplementation(IMPLEMENTATION arg); boolean setPenalty(float arg); boolean setEpsilon(float arg); boolean setTolerance (float arg); boolean setDegree(float arg); boolean setKappa(float arg); boolean setDelta(float arg); boolean setGamma(float arg); boolean setVerbosity(Integral::DEBUG verbosity); boolean setOutputFile(Filename& arg); boolean setOutputType(TYPE arg); boolean init(); boolean loadRawFeatures(Filename& arg); boolean loadFeatures(Sdb& in_sdb, Sdb& out_sdb); boolean train(); boolean writeModel();
description:Sdb pos_sdb; Sdb neg_sdb; svm.loadFeatures(pos_sdb, neg_sdb); svm.train(); svm.writeModel();
enum ALGORITHM { SEQUENTIAL_MINIMAL_OPTIMIZATION = 0, DEF_ALGORITHM = SEQUENTIAL_MINIMAL_OPTIMIZATION };
enum IMPLEMENTATION { LINEAR = 0, POLYNOMIAL, RBF, SIGMOID, DEF_IMPLEMENTATION = LINEAR };
enum TYPE { TEXT = 0, BINARY, DEF_TYPE = BINARY };
static const String CLASS_NAME;
static const NameMap IMPL_MAP;
static const NameMap ALGO_MAP;
static const NameMap TYPE_MAP;
static const String DEF_PARAM;
static const String DEF_COMMENT_TAG;
static const String PARAM_OUTPUT_TYPE;
static const String PARAM_OUTPUT_FILE;
static const String PARAM_AUDIO_DB;
static const String PARAM_PENALTY;
static const String PARAM_EPSILON;
static const String PARAM_TOLERANCE;
static const String PARAM_POLYNOMIAL_DEGREE;
static const String PARAM_RBF_GAMMA;
static const String PARAM_SIGMOID_KAPPA;
static const String PARAM_SIGMOID_DELTA;
static const String PARAM_ALGORITHM;
static const String PARAM_IMPLEMENTATION;
static const long DEF_MAX_POINTS = 0;
static const long DEF_CAPACITY = 1000;
static const float DEF_BIAS = 0.0;
static const float DEF_PENALTY = 0.05;
static const float DEF_EPSILON = 0.001;
static const float DEF_TOLERANCE = 0.001;
static const float DEF_POLYNOMIAL_DEGREE = 3.0;
static const float DEF_RBF_GAMMA = 0.5;
static const float DEF_SIGMOID_KAPPA = 1.0;
static const float DEF_SIGMOID_DELTA = 1.0;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
TYPE output_type_d;
Filename output_file_d;
Filename audio_db_file_d;
AudioDatabase audio_db_d;
Kernel kernel_d;
Float polynomial_degree_d;
Float rbf_gamma_d;
Float sigmoid_kappa_d;
Float sigmoid_delta_d;
VectorFloat alpha_d;
Float penalty_d;
Float tol_d;
Float eps_d;
Long max_points_d;
Float bias_d;
VectorFloat error_cache_d;
Vector<VectorFloat> points_d;
VectorFloat target_d;
static Integral::DEBUG verbosity_d;
static Integral::DEBUG debug_level_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
static boolean setDebug(Integral::DEBUG level);
boolean debug(const unichar* msg) const;
~SupportVectorMachine();
SupportVectorMachine();
SupportVectorMachine(const SupportVectorMachine& arg);
boolean assign(const SupportVectorMachine& copy_node);
SupportVectorMachine& operator= (const SupportVectorMachine& arg);
long sofSize() const;
boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);
boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
boolean eq(const SupportVectorMachine& arg) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);
ALGORITHM getAlgorithm();
boolean setAlgorithm(ALGORITHM arg);
IMPLEMENTATION getImplementation();
boolean setImplementation(IMPLEMENTATION arg);
boolean setPenalty(float arg);
boolean setEpsilon(float arg);
boolean setTolerance (float arg);
boolean setDegree(float arg);
boolean setKappa(float arg);
boolean setDelta(float arg);
boolean setGamma(float arg);
boolean setVerbosity(Integral::DEBUG verbosity);
boolean setOutputFile(Filename& arg);
boolean setOutputType(TYPE arg);
boolean init();
boolean loadRawFeatures(Filename& arg);
boolean loadFeatures(Sdb& in_sdb, Sdb& out_sdb);
boolean train();
boolean writeModel();
boolean sequentialMinimalOptimization();
float evaluateOutput(VectorFloat& point);
int takeStep(int i1, int i2);
int examineExample(int i2);
// open the positive examples file
//
Sof pos_sof;
if (!pos_sof.open(L"positive_examples_list.sof", File::READ_ONLY)) {
output.assign(L"\ncannot open file: ");
output.concat(pos_example_list);
output.concat(L", bailing out...");
Console::put(output);
Integral::exit();
}
// read the list of positive examples
//
Sdb pos_sdb;
if (!pos_sdb.read(pos_sof, (long)0)) {
output.assign(L"\ncannot read file: ");
output.concat(pos_example_list);
output.concat(L", bailing out...");
Console::put(output);
Integral::exit();
}
// open the negative examples file
//
Sof neg_sof;
if (!neg_sof.open(L"negative_examples_list.sof", File::READ_ONLY)) {
output.assign(L"\ncannot open file: ");
output.concat(neg_example_list);
output.concat(L", bailing out...");
Console::put(output);
Integral::exit();
}
// read the list of positive examples
//
Sdb neg_sdb;
if (!neg_sdb.read(neg_sof, (long)0)) {
output.assign(L"\ncannot read file: ");
output.concat(neg_example_list);
output.concat(L", bailing out...");
Console::put(output);
Integral::exit();
}
// open the support vector parameter file
//
if (verbosity >= Integral::BRIEF) {
Console::increaseIndention();
output.assign(L"\nloading parameter file: ");
output.concat(params_file);
Console::put(output);
Console::decreaseIndention();
}
Sof param_sof;
if (!param_sof.open(params_file, File::READ_ONLY)) {
output.assign(L"\ncannot open file: ");
output.concat(params_file);
output.concat(L", bailing out...");
Console::put(output);
Integral::exit();
}
// read the support vector parameters
//
if (!svm.read(param_sof, (long)0)) {
output.assign(L"\nerror reading parameter file: ");
output.concat(params_file);
output.concat(L", bailing out...");
Console::put(output);
Integral::exit();
}
// load the features from file
//
svm.loadFeatures(pos_sdb, neg_sdb);
// start training
//
svm.train();
// write the support vector model
//
svm.writeModel();
notes: