SHOGUN
v1.1.0
|
The class Features is the base class of all feature objects.
It can be understood as a dense real valued feature matrix (with e.g. columns as single feature vectors), a set of strings, graphs or any other arbitrary collection of objects. As a result this class is kept very general and implements only very weak interfaces to
obtain the number of feature "vectors"
In addition it provides helpers to check e.g. for compability of feature objects.
Currently there are 3 general feature classes, which are CSimpleFeatures (dense matrices), CSparseFeatures (sparse matrices), CStringFeatures (a set of strings) from which all the specific features like CSimpleFeatures<float64_t> (dense real valued feature matrices) are derived.
Subsets may be supported by inheriting classes. Sub-classes may want to overwrite the subset_changed_post() method which is called automatically after each subset change
Definition at line 56 of file Features.h.
Public Member Functions | |
CFeatures (int32_t size=0) | |
CFeatures (const CFeatures &orig) | |
CFeatures (CFile *loader) | |
virtual CFeatures * | duplicate () const =0 |
virtual | ~CFeatures () |
virtual EFeatureType | get_feature_type ()=0 |
virtual EFeatureClass | get_feature_class ()=0 |
virtual int32_t | add_preprocessor (CPreprocessor *p) |
set preprocessor | |
virtual CPreprocessor * | del_preprocessor (int32_t num) |
del current preprocessor | |
CPreprocessor * | get_preprocessor (int32_t num) |
get current preprocessor | |
void | set_preprocessed (int32_t num) |
bool | is_preprocessed (int32_t num) |
int32_t | get_num_preprocessed () |
get whether specified preprocessor (or all if num=1) was/were already applied | |
int32_t | get_num_preprocessors () const |
void | clean_preprocessors () |
int32_t | get_cache_size () |
virtual int32_t | get_num_vectors () const =0 |
virtual bool | reshape (int32_t num_features, int32_t num_vectors) |
virtual int32_t | get_size ()=0 |
void | list_feature_obj () |
virtual void | load (CFile *loader) |
virtual void | save (CFile *writer) |
bool | check_feature_compatibility (CFeatures *f) |
bool | has_property (EFeatureProperty p) |
void | set_property (EFeatureProperty p) |
void | unset_property (EFeatureProperty p) |
virtual void | set_subset (CSubset *subset) |
virtual void | remove_subset () |
virtual void | subset_changed_post () |
index_t | subset_idx_conversion (index_t idx) const |
bool | has_subset () const |
virtual CFeatures * | copy_subset (SGVector< index_t > indices) |
![]() | |
CSGObject () | |
CSGObject (const CSGObject &orig) | |
virtual | ~CSGObject () |
virtual const char * | get_name () const =0 |
virtual bool | is_generic (EPrimitiveType *generic) const |
template<class T > | |
void | set_generic () |
void | unset_generic () |
virtual void | print_serializable (const char *prefix="") |
virtual bool | save_serializable (CSerializableFile *file, const char *prefix="") |
virtual bool | load_serializable (CSerializableFile *file, const char *prefix="") |
void | set_global_io (SGIO *io) |
SGIO * | get_global_io () |
void | set_global_parallel (Parallel *parallel) |
Parallel * | get_global_parallel () |
void | set_global_version (Version *version) |
Version * | get_global_version () |
SGVector< char * > | get_modelsel_names () |
char * | get_modsel_param_descr (const char *param_name) |
index_t | get_modsel_param_index (const char *param_name) |
Protected Attributes | |
CSubset * | m_subset |
Additional Inherited Members | |
![]() | |
SGIO * | io |
Parallel * | parallel |
Version * | version |
Parameter * | m_parameters |
Parameter * | m_model_selection_parameters |
![]() | |
virtual void | load_serializable_pre () throw (ShogunException) |
virtual void | load_serializable_post () throw (ShogunException) |
virtual void | save_serializable_pre () throw (ShogunException) |
virtual void | save_serializable_post () throw (ShogunException) |
CFeatures | ( | int32_t | size = 0 | ) |
copy constructor
Definition at line 29 of file Features.cpp.
constructor
loader | File object via which data shall be loaded |
Definition at line 41 of file Features.cpp.
|
virtual |
Definition at line 50 of file Features.cpp.
|
virtual |
set preprocessor
add preprocessor
p | preprocessor to set |
Definition at line 82 of file Features.cpp.
bool check_feature_compatibility | ( | CFeatures * | f | ) |
check feature compatibility
f | features to check for compatibility |
Definition at line 327 of file Features.cpp.
void clean_preprocessors | ( | ) |
clears all preprocs
Definition at line 138 of file Features.cpp.
Creates a new CFeatures instance containing copies of the elements which are specified by the provided indices.
This method is needed for a KernelMachine to store its model data. NOT IMPLEMENTED!
indices | indices of feature elements to copy |
Reimplemented in CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, CStringFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, and CSimpleFeatures< uint16_t >.
Definition at line 375 of file Features.cpp.
|
virtual |
del current preprocessor
delete preprocessor from list caller has to clean up returned preproc
num | index of preprocessor in list |
Definition at line 144 of file Features.cpp.
|
pure virtual |
duplicate feature object
abstract base method
Implemented in CStreamingSparseFeatures< T >, CStreamingSimpleFeatures< T >, CCombinedDotFeatures, CStreamingStringFeatures< T >, CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, CStringFeatures< uint16_t >, CWDFeatures, CHashedWDFeatures, CSparsePolyFeatures, CHashedWDFeaturesTransposed, CLBPPyrDotFeatures, CSNPFeatures, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CAttributeFeatures, CPolyFeatures, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CStreamingVwFeatures, CImplicitWeightedSpecFeatures, CExplicitSpecFeatures, CDummyFeatures, and CCombinedFeatures.
int32_t get_cache_size | ( | ) |
|
pure virtual |
get feature class
abstract base method
Implemented in CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CStreamingSparseFeatures< T >, CStreamingVwFeatures, CStreamingSimpleFeatures< T >, CStreamingStringFeatures< T >, CHashedWDFeatures, CWDFeatures, CExplicitSpecFeatures, CCombinedDotFeatures, CHashedWDFeaturesTransposed, CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, CStringFeatures< uint16_t >, CSNPFeatures, CAttributeFeatures, CImplicitWeightedSpecFeatures, CSparsePolyFeatures, CPolyFeatures, CLBPPyrDotFeatures, CCombinedFeatures, and CDummyFeatures.
|
pure virtual |
get feature type
abstract base method
Implemented in CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CStringFeatures< ST >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CStreamingSparseFeatures< T >, CStreamingVwFeatures, CStreamingSimpleFeatures< T >, CStreamingStringFeatures< T >, CWDFeatures, CHashedWDFeatures, CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, CStringFeatures< uint16_t >, CExplicitSpecFeatures, CCombinedDotFeatures, CHashedWDFeaturesTransposed, CSNPFeatures, CAttributeFeatures, CImplicitWeightedSpecFeatures, CSparsePolyFeatures, CPolyFeatures, CLBPPyrDotFeatures, CCombinedFeatures, and CDummyFeatures.
int32_t get_num_preprocessed | ( | ) |
get whether specified preprocessor (or all if num=1) was/were already applied
get the number of applied preprocs
Definition at line 124 of file Features.cpp.
int32_t get_num_preprocessors | ( | ) | const |
get number of preprocessors
Definition at line 199 of file Features.cpp.
|
pure virtual |
get number of examples/vectors, possibly corresponding to the current subset
abstract base method
Implemented in CStreamingSparseFeatures< T >, CStreamingVwFeatures, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, CStringFeatures< uint16_t >, CStreamingSimpleFeatures< T >, CStreamingStringFeatures< T >, CHashedWDFeatures, CWDFeatures, CExplicitSpecFeatures, CHashedWDFeaturesTransposed, CSNPFeatures, CAttributeFeatures, CImplicitWeightedSpecFeatures, CSparsePolyFeatures, CPolyFeatures, CLBPPyrDotFeatures, CCombinedFeatures, CCombinedDotFeatures, and CDummyFeatures.
CPreprocessor * get_preprocessor | ( | int32_t | num | ) |
get current preprocessor
get specified preprocessor
num | index of preprocessor in list |
Definition at line 112 of file Features.cpp.
|
pure virtual |
get memory footprint of one feature
abstract base method
Implemented in CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, CStringFeatures< uint16_t >, CStreamingSparseFeatures< T >, CStreamingVwFeatures, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CStreamingSimpleFeatures< T >, CStreamingStringFeatures< T >, CHashedWDFeatures, CWDFeatures, CExplicitSpecFeatures, CCombinedDotFeatures, CHashedWDFeaturesTransposed, CSNPFeatures, CAttributeFeatures, CImplicitWeightedSpecFeatures, CSparsePolyFeatures, CPolyFeatures, CLBPPyrDotFeatures, CCombinedFeatures, and CDummyFeatures.
bool has_property | ( | EFeatureProperty | p | ) |
check if features have given property
p | feature property |
Definition at line 337 of file Features.cpp.
bool has_subset | ( | ) | const |
bool is_preprocessed | ( | int32_t | num | ) |
get whether specified preprocessor was already applied
num | index of preprocessor in list |
Definition at line 194 of file Features.cpp.
void list_feature_obj | ( | ) |
list feature object
Definition at line 215 of file Features.cpp.
|
virtual |
load features from file
loader | File object via which data shall be loaded |
Reimplemented in CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, CSparseFeatures< T >, CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, and CStringFeatures< uint16_t >.
Definition at line 313 of file Features.cpp.
|
virtual |
deletes any set subset subset_changed_post() is called afterwards
Definition at line 370 of file Features.cpp.
|
virtual |
in case there is a feature matrix allow for reshaping
NOT IMPLEMENTED!
num_features | new number of features |
num_vectors | new number of vectors |
Reimplemented in CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, and CSimpleFeatures< uint16_t >.
Definition at line 209 of file Features.cpp.
|
virtual |
save features to file
writer | File object via which data shall be saved |
Reimplemented in CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, CStringFeatures< uint16_t >, CSimpleFeatures< ST >, CSimpleFeatures< uint32_t >, CSimpleFeatures< float64_t >, CSimpleFeatures< T >, CSimpleFeatures< uint16_t >, CSparseFeatures< ST >, CSparseFeatures< float64_t >, and CSparseFeatures< T >.
Definition at line 320 of file Features.cpp.
void set_preprocessed | ( | int32_t | num | ) |
set applied flag for preprocessor
num | index of preprocessor in list |
Definition at line 189 of file Features.cpp.
void set_property | ( | EFeatureProperty | p | ) |
|
virtual |
setter for subset variable, deletes old one subset_changed_post() is called afterwards
subset | subset instance to set |
Definition at line 352 of file Features.cpp.
|
virtual |
method may be overwritten to update things that depend on subset
Reimplemented in CStringFeatures< ST >, CStringFeatures< T >, CStringFeatures< uint8_t >, CStringFeatures< char >, and CStringFeatures< uint16_t >.
Definition at line 234 of file Features.h.
does subset index conversion with the underlying subset if possible
idx | index to convert |
Definition at line 360 of file Features.cpp.
void unset_property | ( | EFeatureProperty | p | ) |
|
protected |
subset class to enable subset support for this class
Definition at line 278 of file Features.h.