/usr/include/shogun/features/Features.h is in libshogun-dev 1.1.0-4ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 1999-2009 Soeren Sonnenburg
* Written (W) 1999-2008 Gunnar Raetsch
* Subset support written (W) 2011 Heiko Strathmann
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
*/
#ifndef _CFEATURES__H__
#define _CFEATURES__H__
#include <shogun/lib/common.h>
#include <shogun/io/File.h>
#include <shogun/base/SGObject.h>
#include <shogun/preprocessor/Preprocessor.h>
#include <shogun/features/FeatureTypes.h>
#include <shogun/features/Subset.h>
namespace shogun
{
class CFile;
class CPreprocessor;
class CKernel;
}
namespace shogun
{
/** @brief 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
*
* - duplicate the Feature object
* - obtain the feature type (like F_DREAL, F_SHORT ...)
* - obtain the feature class (like Simple dense matrices, sparse or strings)
* - 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
*/
class CFeatures : public CSGObject
{
void init();
public:
/** constructor
*
* @param size cache size
*/
CFeatures(int32_t size=0);
/** copy constructor */
CFeatures(const CFeatures& orig);
/** constructor
*
* @param loader File object via which data shall be loaded
*/
CFeatures(CFile* loader);
/** duplicate feature object
*
* abstract base method
*
* @return feature object
*/
virtual CFeatures* duplicate() const=0;
virtual ~CFeatures();
/** get feature type
*
* abstract base method
*
* @return templated feature type
*/
virtual EFeatureType get_feature_type()=0;
/** get feature class
*
* abstract base method
*
* @return feature class like STRING, SIMPLE, SPARSE...
*/
virtual EFeatureClass get_feature_class()=0;
/** add preprocessor
*
* @param p preprocessor to set
* @return something inty
*/
virtual int32_t add_preprocessor(CPreprocessor* p);
/** delete preprocessor from list
* caller has to clean up returned preproc
*
* @param num index of preprocessor in list
*/
virtual CPreprocessor* del_preprocessor(int32_t num);
/** get specified preprocessor
*
* @param num index of preprocessor in list
*/
CPreprocessor* get_preprocessor(int32_t num);
/** set applied flag for preprocessor
*
* @param num index of preprocessor in list
*/
void set_preprocessed(int32_t num);
/** get whether specified preprocessor was already applied
*
* @param num index of preprocessor in list
*/
bool is_preprocessed(int32_t num);
/** get the number of applied preprocs
*
* @return number of applied preprocessors
*/
int32_t get_num_preprocessed();
/** get number of preprocessors
*
* @return number of preprocessors
*/
int32_t get_num_preprocessors() const;
/** clears all preprocs */
void clean_preprocessors();
/** get cache size
*
* @return cache size
*/
int32_t get_cache_size();
/** get number of examples/vectors, possibly corresponding to the current subset
*
* abstract base method
*
* @return number of examples/vectors (possibly of subset, if implemented)
*/
virtual int32_t get_num_vectors() const=0;
/** in case there is a feature matrix allow for reshaping
*
* NOT IMPLEMENTED!
*
* @param num_features new number of features
* @param num_vectors new number of vectors
* @return if reshaping was successful
*/
virtual bool reshape(int32_t num_features, int32_t num_vectors);
/** get memory footprint of one feature
*
* abstract base method
*
* @return memory footprint of one feature
*/
virtual int32_t get_size()=0;
/** list feature object */
void list_feature_obj();
/** load features from file
*
* @param loader File object via which data shall be loaded
*/
virtual void load(CFile* loader);
/** save features to file
*
* @param writer File object via which data shall be saved
*/
virtual void save(CFile* writer);
/** check feature compatibility
*
* @param f features to check for compatibility
* @return if features are compatible
*/
bool check_feature_compatibility(CFeatures* f);
/** check if features have given property
*
* @param p feature property
* @return if features have given property
*/
bool has_property(EFeatureProperty p);
/** set property
*
* @param p kernel property to set
*/
void set_property(EFeatureProperty p);
/** unset property
*
* @param p kernel property to unset
*/
void unset_property(EFeatureProperty p);
/** setter for subset variable, deletes old one
* subset_changed_post() is called afterwards
*
* @param subset subset instance to set
*/
virtual void set_subset(CSubset* subset);
/** deletes any set subset
* subset_changed_post() is called afterwards */
virtual void remove_subset();
/** method may be overwritten to update things that depend on subset */
virtual void subset_changed_post() {}
/** does subset index conversion with the underlying subset if possible
*
* @param idx index to convert
* @return converted index
*/
index_t subset_idx_conversion(index_t idx) const;
/** check if has subsets
* @return true if has subsets
*/
bool has_subset() const;
/** 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!
*
* @param indices indices of feature elements to copy
* @return new CFeatures instance with copies of feature data
*/
virtual CFeatures* copy_subset(SGVector<index_t> indices);
private:
/** feature properties */
uint64_t properties;
/// size of cache in MB
int32_t cache_size;
/// list of preprocessors
CPreprocessor** preproc;
/// number of preprocs in list
int32_t num_preproc;
/// i'th entry is true if features were already preprocessed with preproc i
bool* preprocessed;
protected:
/** subset class to enable subset support for this class */
CSubset* m_subset;
};
}
#endif
|