SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUIFeatures.h
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  * Written (W) 1999-2008 Gunnar Raetsch
9  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef __GUIFEATURES__H
13 #define __GUIFEATURES__H
14 
15 #include <shogun/lib/config.h>
16 #include <shogun/base/SGObject.h>
17 #include <shogun/labels/Labels.h>
30 
31 namespace shogun
32 {
33 class CSGInterface;
34 
36 class CGUIFeatures : public CSGObject
37 {
39  enum EFeatureType
40  {
41  Simple,
42  Sparse
43  };
44 
45  public:
51  CGUIFeatures(CSGInterface* interface);
53  ~CGUIFeatures();
54 
59 
63  inline bool set_train_features(CFeatures* f)
64  {
65  //invalidate_train();
66  SG_REF(f);
69  return true;
70  }
71 
75  inline bool set_test_features(CFeatures* f)
76  {
77  //invalidate_test();
78  SG_REF(f);
80  test_features=f;
81  return true;
82  }
83 
100 
102  bool del_last_feature_obj(char* target);
103 
105  void invalidate_train();
107  void invalidate_test();
108 
110  bool load(
111  char* filename, char* fclass, char* type, char* target,
112  int32_t size, int32_t comp_features);
114  bool save(char* filename, char* type, char* target);
116  bool clean(char* target);
118  bool reshape(char* target, int32_t num_feat, int32_t num_vec);
119 
121  CFeatures* get_convert_features(char* target);
123  bool set_convert_features(CFeatures* features, char* target);
124 
134  CDenseFeatures<char>* src);
141  float64_t gap_cost=0);
147 
168  CStringFeatures<uint16_t>* src, bool use_norm);
169 
178  template <class CT, class ST>
180  CStringFeatures<CT>* src,
181  int32_t order=1, int32_t start=0, int32_t gap=0, char rev='f', CAlphabet* alpha=NULL)
182  {
183  if (src && src->get_feature_class()==C_STRING)
184  {
185  //create dense features with 0 cache
186  SG_INFO("Converting CT STRING features to ST STRING ones (order=%i).\n",order)
187  bool free_alpha=false;
188 
189  if (!alpha)
190  {
191  CAlphabet* a = src->get_alphabet();
192 
193  if ( a && a->get_alphabet() == DNA )
194  alpha=new CAlphabet(RAWDNA);
195  else
196  alpha=new CAlphabet(a);
197 
198  free_alpha=true;
199  SG_UNREF(a);
200  }
201 
203  if (sf && sf->obtain_from_char_features(src, start, order, gap, rev=='r'))
204  {
205  SG_INFO("Conversion was successful.\n")
206  return sf;
207  }
208 
209  if (free_alpha)
210  SG_UNREF(alpha);
211  SG_UNREF(sf);
212  }
213  else
214  SG_ERROR("No features of class/type STRING/CT available.\n")
215 
216  return NULL;
217  }
218 
219 
221  bool set_reference_features(char* target);
222 
224  virtual const char* get_name() const { return "GUIFeatures"; }
225 
226  protected:
228  CSGInterface* ui;
235 };
236 }
237 #endif
void add_train_features(CFeatures *f)
CSGInterface * ui
Definition: GUIFeatures.h:228
CFeatures * test_features
Definition: GUIFeatures.h:232
#define SG_INFO(...)
Definition: SGIO.h:118
DNA - letters A,C,G,T.
Definition: Alphabet.h:26
CSGInterface * interface
Definition: SGInterface.cpp:45
CDenseFeatures< float64_t > * convert_simple_word_to_simple_salzberg(CDenseFeatures< uint16_t > *src)
virtual const char * get_name() const
Definition: GUIFeatures.h:224
RAWDNA - letters 0,1,2,3.
Definition: Alphabet.h:29
bool set_test_features(CFeatures *f)
Definition: GUIFeatures.h:75
CTOPFeatures * convert_string_word_to_simple_top(CStringFeatures< uint16_t > *src)
CStringFeatures< char > * convert_simple_char_to_string_char(CDenseFeatures< char > *src)
CExplicitSpecFeatures * convert_string_byte_to_spec_word(CStringFeatures< uint16_t > *src, bool use_norm)
bool load(char *filename, char *fclass, char *type, char *target, int32_t size, int32_t comp_features)
Definition: GUIFeatures.cpp:48
EAlphabet get_alphabet() const
Definition: Alphabet.h:130
#define SG_ERROR(...)
Definition: SGIO.h:129
The class Alphabet implements an alphabet and alphabet utility functions.
Definition: Alphabet.h:91
bool save(char *filename, char *type, char *target)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
bool del_last_feature_obj(char *target)
CFKFeatures * convert_string_word_to_simple_fk(CStringFeatures< uint16_t > *src)
#define SG_REF(x)
Definition: SGObject.h:54
CStringFeatures< ST > * convert_string_char_to_string_generic(CStringFeatures< CT > *src, int32_t order=1, int32_t start=0, int32_t gap=0, char rev='f', CAlphabet *alpha=NULL)
Definition: GUIFeatures.h:179
void add_test_dotfeatures(CDotFeatures *f)
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
bool set_convert_features(CFeatures *features, char *target)
void add_test_features(CFeatures *f)
double float64_t
Definition: common.h:50
CFeatures * ref_features
Definition: GUIFeatures.h:234
CSparseFeatures< float64_t > * convert_simple_real_to_sparse_real(CDenseFeatures< float64_t > *src)
virtual EFeatureClass get_feature_class() const
CFeatures * get_train_features()
Definition: GUIFeatures.h:56
bool set_train_features(CFeatures *f)
Definition: GUIFeatures.h:63
Features that compute the Spectrum Kernel feature space explicitly.
The class TOPFeatures implements TOP kernel features obtained from two Hidden Markov models...
Definition: TOPFeatures.h:70
bool clean(char *target)
#define SG_UNREF(x)
Definition: SGObject.h:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CFeatures * get_test_features()
Definition: GUIFeatures.h:58
CDenseFeatures< float64_t > * convert_simple_char_to_simple_align(CDenseFeatures< char > *src, float64_t gap_cost=0)
The class Features is the base class of all feature objects.
Definition: Features.h:68
bool set_reference_features(char *target)
void add_train_dotfeatures(CDotFeatures *f)
UI features.
Definition: GUIFeatures.h:36
bool reshape(char *target, int32_t num_feat, int32_t num_vec)
CFeatures * train_features
Definition: GUIFeatures.h:230
bool obtain_from_char_features(CStringFeatures< CT > *sf, int32_t start, int32_t p_order, int32_t gap, bool rev)
CDenseFeatures< float64_t > * convert_sparse_real_to_simple_real(CSparseFeatures< float64_t > *src)
The class FKFeatures implements Fischer kernel features obtained from two Hidden Markov models...
Definition: FKFeatures.h:43
CFeatures * get_convert_features(char *target)

SHOGUN Machine Learning Toolbox - Documentation