Skip to content

Commit

Permalink
Cleanup preprocessors
Browse files Browse the repository at this point in the history
  • Loading branch information
vinx13 authored and vigsterkr committed Jun 8, 2018
1 parent 80f36a6 commit 48817a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/shogun/preprocessor/DecompressString.cpp
Expand Up @@ -56,9 +56,9 @@ bool CDecompressString<ST>::apply_to_string_features(CFeatures* f)
{
int32_t len=0;
bool free_vec;
ST* vec = sf->get_feature_vector(i, len, free_vec);
auto vec = sf->get_feature_vector(i, len, free_vec);

ST* decompressed=apply_to_string(vec, len);
auto decompressed=apply_to_string(vec, len);
sf->free_feature_vector(vec, i, free_vec);
sf->cleanup_feature_vector(i);
sf->set_feature_vector(i, decompressed, len);
Expand Down
7 changes: 0 additions & 7 deletions src/shogun/preprocessor/DependenceMaximization.h
Expand Up @@ -114,13 +114,6 @@ class CDependenceMaximization : public CFeatureSelection<float64_t>
*/
virtual void set_algorithm(EFeatureSelectionAlgorithm algorithm)=0;

/**
* Fit preprocessor into features
*
* @param features the features
*/
virtual void fit(CFeatures* features);

/**
* Setter for labels. This method is overridden to internally convert the
* labels to a dense feature object and set this feature in the
Expand Down
10 changes: 6 additions & 4 deletions src/shogun/preprocessor/PruneVarSubMean.cpp
Expand Up @@ -106,7 +106,9 @@ SGMatrix<float64_t> CPruneVarSubMean::apply_to_feature_matrix(CFeatures* feature

int32_t num_vectors=0;
int32_t num_features=0;
float64_t* m=((CDenseFeatures<float64_t>*) features)->get_feature_matrix(num_features, num_vectors);

auto simple_features = features->as<CDenseFeatures<float64_t>>();
auto m = simple_features->get_feature_matrix();

SG_INFO("get Feature matrix: %ix%i\n", num_vectors, num_features)
SG_INFO("Preprocessing feature matrix\n")
Expand All @@ -127,11 +129,11 @@ SGMatrix<float64_t> CPruneVarSubMean::apply_to_feature_matrix(CFeatures* feature
}
}

((CDenseFeatures<float64_t>*) features)->set_num_features(m_num_idx);
((CDenseFeatures<float64_t>*) features)->get_feature_matrix(num_features, num_vectors);
simple_features->set_num_features(m_num_idx);
simple_features->get_feature_matrix(num_features, num_vectors);
SG_INFO("new Feature matrix: %ix%i\n", num_vectors, num_features)

return ((CDenseFeatures<float64_t>*) features)->get_feature_matrix();
return simple_features->get_feature_matrix();
}

/// apply preproc on single feature vector
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/preprocessor/SortWordString.cpp
Expand Up @@ -48,13 +48,13 @@ bool CSortWordString::apply_to_string_features(CFeatures* f)
{
int32_t i;
auto sf = f->as<CStringFeatures<uint16_t>>();
int32_t num_vec = sf->get_num_vectors();
auto num_vec = sf->get_num_vectors();

for (i=0; i<num_vec; i++)
{
int32_t len = 0 ;
bool free_vec;
uint16_t* vec = sf->get_feature_vector(i, len, free_vec);
auto vec = sf->get_feature_vector(i, len, free_vec);
ASSERT(!free_vec) // won't work with non-in-memory string features

//CMath::qsort(vec, len);
Expand Down

0 comments on commit 48817a3

Please sign in to comment.