KernelMachine.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #include "kernel/KernelMachine.h"
00012 
00013 CKernelMachine::CKernelMachine()
00014 : CClassifier(), kernel(NULL), use_batch_computation(true), use_linadd(true)
00015 {
00016 }
00017 
00018 CKernelMachine::~CKernelMachine()
00019 {
00020     SG_UNREF(kernel);
00021 }
00022 
00023 CLabels* CKernelMachine::classify(CLabels* output)
00024 {
00025     if (kernel && kernel->has_features())
00026     {
00027         int32_t num=kernel->get_num_vec_rhs();
00028         ASSERT(num>0);
00029 
00030         if (!output)
00031         {
00032             output=new CLabels(num);
00033             SG_REF(output);
00034         }
00035         ASSERT(output->get_num_labels()==num);
00036 
00037         for (int32_t i=0; i<num; i++)
00038             output->set_label(i, classify_example(i));
00039 
00040         return output;
00041     }
00042 
00043     return NULL;
00044 }

SHOGUN Machine Learning Toolbox - Documentation