SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUILabels.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2008 Soeren Sonnenburg
8  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #include <shogun/ui/GUILabels.h>
12 #include <shogun/ui/SGInterface.h>
13 
14 #include <shogun/lib/config.h>
15 #include <shogun/io/SGIO.h>
16 #include <shogun/io/AsciiFile.h>
17 #include <shogun/features/Labels.h>
18 
19 #include <string.h>
20 
21 using namespace shogun;
22 
23 CGUILabels::CGUILabels(CSGInterface* ui_)
24 : CSGObject(), ui(ui_), train_labels(NULL), test_labels(NULL)
25 {
26 }
27 
29 {
32 }
33 
34 bool CGUILabels::load(char* filename, char* target)
35 {
36  CLabels* labels=NULL;
37 
38  if (strncmp(target, "TEST", 4)==0)
39  labels=test_labels;
40  else if (strncmp(target, "TRAIN", 5)==0)
41  labels=train_labels;
42  else
43  SG_ERROR("Invalid target %s.\n", target);
44 
45  if (labels)
46  {
47  SG_UNREF(labels);
48  CAsciiFile* file=new CAsciiFile(filename);
49  labels=new CLabels(file);
50 
51  if (labels)
52  {
53  if (strncmp(target, "TEST", 4)==0)
54  set_test_labels(labels);
55  else
56  set_train_labels(labels);
57 
58  return true;
59  }
60  else
61  SG_ERROR("Loading labels failed.\n");
62 
63  SG_UNREF(file);
64  }
65 
66  return false;
67 }
68 
69 bool CGUILabels::save(char* param)
70 {
71  bool result=false;
72  return result;
73 }
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:35
#define SG_ERROR(...)
Definition: SGIO.h:75
bool save(char *param)
Definition: GUILabels.cpp:69
A Ascii File access class.
Definition: AsciiFile.h:35
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:76
#define SG_UNREF(x)
Definition: SGObject.h:45
bool set_test_labels(CLabels *lab)
Definition: GUILabels.h:48
bool load(char *filename, char *target)
Definition: GUILabels.cpp:34
CLabels * test_labels
Definition: GUILabels.h:69
bool set_train_labels(CLabels *lab)
Definition: GUILabels.h:44
CLabels * train_labels
Definition: GUILabels.h:67

SHOGUN Machine Learning Toolbox - Documentation