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-2008 Soeren Sonnenburg 00008 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #include "classifier/LinearClassifier.h" 00012 00013 CLinearClassifier::CLinearClassifier() 00014 : CClassifier(), w_dim(0), w(NULL), bias(0), features(NULL) 00015 { 00016 } 00017 00018 CLinearClassifier::~CLinearClassifier() 00019 { 00020 delete[] w; 00021 SG_UNREF(features); 00022 } 00023 00024 bool CLinearClassifier::load(FILE* srcfile) 00025 { 00026 return false; 00027 } 00028 00029 bool CLinearClassifier::save(FILE* dstfile) 00030 { 00031 return false; 00032 } 00033 00034 CLabels* CLinearClassifier::classify(CLabels* output) 00035 { 00036 if (features) 00037 { 00038 int32_t num=features->get_num_vectors(); 00039 ASSERT(num>0); 00040 ASSERT(w_dim==features->get_num_features()); 00041 00042 if (!output) 00043 output=new CLabels(num); 00044 ASSERT(output->get_num_labels()==num); 00045 00046 for (int32_t i=0; i<num; i++) 00047 output->set_label(i, classify_example(i)); 00048 00049 return output; 00050 } 00051 00052 return NULL; 00053 }