50 SG_ADD(&m_target_dim,
"target_dim",
"target dimension",
56 SG_ADD(&m_num_remove,
"num_remove",
"number or percentage of features to "
82 m_subset->remove_all_subsets();
94 index_t num_features=get_num_features(features);
95 SG_DEBUG(
"Initial number of features %d!\n", num_features);
98 while (num_features>m_target_dim)
102 adapt_params(features);
106 for (
index_t i=0; i<num_features; ++i)
107 measures[i]=compute_measures(features, i);
121 to_remove=m_num_remove;
123 to_remove=num_features*m_num_remove*0.01;
125 index_t can_remove=num_features-m_target_dim;
131 index_t orig_remove=m_num_remove;
134 if (to_remove>can_remove)
136 m_num_remove=can_remove;
137 SG_DEBUG(
"Can only remove %d features in this iteration!\n",
149 features=remove_feats(features, argsorted);
153 if (to_remove>can_remove)
155 m_policy=orig_policy;
156 m_num_remove=orig_remove;
160 num_features=get_num_features(features);
161 SG_DEBUG(
"Current number of features %d!\n", num_features);
165 ASSERT(m_subset->get_size()==m_target_dim);
177 m_subset->remove_all_subsets();
180 REQUIRE(features,
"Features cannot be NULL!\n");
182 "Number of feature vectors has to be positive!\n");
183 REQUIRE(m_target_dim>0,
"Target dimension (%d) has to be positive! Set "
184 "a higher number via set_target_dim().\n", m_target_dim);
186 index_t num_features=get_num_features(features);
187 REQUIRE(num_features>0,
"Invalid number of features (%d)! Most likely "
188 "feature selection cannot be performed for %s!\n",
189 num_features, features->
get_name());
190 REQUIRE(num_features>m_target_dim,
191 "Number of original features (dimensions of the feature vectors) "
192 "(%d) has to be greater that the target dimension (%d)!\n",
193 num_features, m_target_dim);
203 return apply_backward_elimination(feats_copy);
205 SG_ERROR(
"Specified algorithm not yet supported!\n");
228 if (m_subset->has_subsets())
232 inds[i]=m_subset->subset_idx_conversion(i);
242 REQUIRE(features,
"Features not initialized!\n");
251 REQUIRE(d_feats,
"Type mismatch for dense features!\n");
257 REQUIRE(s_feats,
"Type mismatch for sparse features!\n");
261 SG_ERROR(
"Number of features not available for %s!\n",
272 m_target_dim=target_dim;
296 m_num_remove=num_remove;
virtual const char * get_name() const =0
virtual void adapt_params(CFeatures *features)
The class DenseFeatures implements dense feature matrices.
int32_t get_num_features() const
SGVector< index_t > get_selected_feats()
The class Labels models labels, i.e. class assignments of objects.
virtual CSGObject * clone()
Template class SparseFeatures implements sparse matrices.
virtual int32_t get_num_vectors() const =0
virtual EPreprocessorType get_type() const
EFeatureClass
shogun feature class
class to add subset support to another class. A CSubsetStackStack instance should be added and wrappe...
Template class CFeatureSelection, base class for all feature selection preprocessors which select a s...
void display_vector(const char *name="vector", const char *prefix="") const
void set_num_remove(index_t num_remove)
EFeatureSelectionAlgorithm get_algorithm() const
SGVector< index_t > argsort()
virtual void set_labels(CLabels *labels)
virtual CFeatures * apply_backward_elimination(CFeatures *features)
Class SGObject is the base class of all shogun objects.
int32_t get_num_features() const
virtual void precompute()
EFeatureRemovalPolicy get_policy() const
virtual EFeatureClass get_feature_class()
virtual EFeatureClass get_feature_class() const =0
EFeatureType
shogun feature type
virtual EFeatureType get_feature_type()
all of classes and functions are contained in the shogun namespace
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()
virtual CFeatures * apply(CFeatures *features)
index_t get_num_remove() const
CLabels * get_labels() const
index_t get_target_dim() const