49 SG_ADD(&m_target_dim,
"target_dim",
"target dimension",
55 SG_ADD(&m_num_remove,
"num_remove",
"number or percentage of features to "
88 index_t num_features=get_num_features(features);
89 SG_DEBUG(
"Initial number of features %d!\n", num_features);
92 while (num_features>m_target_dim)
96 adapt_params(features);
100 for (
index_t i=0; i<num_features; ++i)
101 measures[i]=compute_measures(features, i);
115 to_remove=m_num_remove;
117 to_remove=num_features*m_num_remove*0.01;
119 index_t can_remove=num_features-m_target_dim;
125 index_t orig_remove=m_num_remove;
128 if (to_remove>can_remove)
130 m_num_remove=can_remove;
131 SG_DEBUG(
"Can only remove %d features in this iteration!\n",
142 features=remove_feats(features, argsorted);
146 if (to_remove>can_remove)
148 m_policy=orig_policy;
149 m_num_remove=orig_remove;
153 num_features=get_num_features(features);
154 SG_DEBUG(
"Current number of features %d!\n", num_features);
167 REQUIRE(features,
"Features cannot be NULL!\n");
169 "Number of feature vectors has to be positive!\n");
170 REQUIRE(m_target_dim>0,
"Target dimension (%d) has to be positive! Set "
171 "a higher number via set_target_dim().\n", m_target_dim);
173 index_t num_features=get_num_features(features);
174 REQUIRE(num_features>0,
"Invalid number of features (%d)! Most likely "
175 "feature selection cannot be performed for %s!\n",
176 num_features, features->
get_name());
177 REQUIRE(num_features>m_target_dim,
178 "Number of original features (dimensions of the feature vectors) "
179 "(%d) has to be greater that the target dimension (%d)!\n",
180 num_features, m_target_dim);
190 return apply_backward_elimination(feats_copy);
192 SG_ERROR(
"Specified algorithm not yet supported!\n");
212 REQUIRE(features,
"Features not initialized!\n");
221 REQUIRE(d_feats,
"Type mismatch for dense features!\n");
227 REQUIRE(s_feats,
"Type mismatch for sparse features!\n");
231 SG_ERROR(
"Number of features not available for %s!\n",
242 m_target_dim=target_dim;
266 m_num_remove=num_remove;
virtual const char * get_name() const =0
virtual void adapt_params(CFeatures *features)
The class Labels models labels, i.e. class assignments of objects.
virtual CSGObject * clone()
virtual int32_t get_num_vectors() const =0
int32_t get_num_features() const
virtual EPreprocessorType get_type() const
EFeatureClass
shogun feature class
Template class CFeatureSelection, base class for all feature selection preprocessors which select a s...
void set_num_remove(index_t num_remove)
EFeatureSelectionAlgorithm get_algorithm() const
virtual void set_labels(CLabels *labels)
virtual CFeatures * apply_backward_elimination(CFeatures *features)
Class SGObject is the base class of all shogun objects.
virtual void precompute()
EFeatureRemovalPolicy get_policy() const
virtual EFeatureClass get_feature_class()
virtual EFeatureClass get_feature_class() const =0
int32_t get_num_features() const
EFeatureType
shogun feature type
The class DenseFeatures implements dense feature matrices.
virtual EFeatureType get_feature_type()
index_t get_num_features(CFeatures *features) const
The class Features is the base class of all feature objects.
EFeatureSelectionAlgorithm
Class Preprocessor defines a preprocessor interface.
void set_target_dim(index_t target_dim)
virtual ~CFeatureSelection()
SGVector< index_t > argsort()
void display_vector(const char *name="vector", const char *prefix="") const
virtual CFeatures * apply(CFeatures *features)
index_t get_num_remove() const
CLabels * get_labels() const
index_t get_target_dim() const