Skip to content

Cleanup and optimize transformers - #4348

Merged
vigsterkr merged 6 commits into
shogun-toolbox:feature/transformersfrom
vinx13:feature/transformers_update
Jul 11, 2018
Merged

Cleanup and optimize transformers#4348
vigsterkr merged 6 commits into
shogun-toolbox:feature/transformersfrom
vinx13:feature/transformers_update

Conversation

@vinx13

@vinx13 vinx13 commented Jun 28, 2018

Copy link
Copy Markdown
Member
  • Use linalg in NormOne
  • Optimize PruneVarSubMean

@vinx13 vinx13 changed the title Cleanup and optimize code transformers Cleanup and optimize transformers Jun 28, 2018
@vigsterkr
vigsterkr force-pushed the feature/transformers branch from 550639e to af8af72 Compare June 28, 2018 10:49
@karlnapf

Copy link
Copy Markdown
Member

This needs a rebase

@karlnapf

Copy link
Copy Markdown
Member

Btw whenever you make something linalg, pls ensure there is some test coverage of the changes lines, so that we at least know he results didn’t change in the integration test examples

@vinx13
vinx13 force-pushed the feature/transformers_update branch from dedcb4a to bdacb07 Compare June 28, 2018 10:58
EXPECT_EQ(v.vlen, num_features);
for (auto j : range(v.vlen))
{
EXPECT_DOUBLE_EQ(v[j], data[num_features * i + j] / norm[i]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant we use operator() here?

{
SGVector<float64_t> v = feats->get_feature_vector(i);
auto result = transformer->apply_to_feature_vector(v);
EXPECT_EQ(result.vlen, num_features);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT_EQ to avoid segfault

CPruneVarSubMean::apply_to_matrix(SGMatrix<float64_t> matrix)
{
ASSERT(m_initialized)
REQUIRE(m_initialized, "Transformer has not been fitted.\n");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

offtopic: I would love to move all those general checks to base classes so that they dont get repeated in every specialization....
any thoughts on this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we use a different exception type other than ShogunException

@vigsterkr
vigsterkr force-pushed the feature/transformers branch 2 times, most recently from 77a9f85 to 8711ea6 Compare July 10, 2018 15:12
@vinx13
vinx13 force-pushed the feature/transformers_update branch from c1b0299 to 47363cb Compare July 10, 2018 15:27
@vinx13
vinx13 force-pushed the feature/transformers_update branch from 47363cb to 918fead Compare July 11, 2018 00:57
CPruneVarSubMean::apply_to_matrix(SGMatrix<float64_t> matrix)
{
ASSERT(m_initialized)
REQUIRE(m_initialized, "Transformer has not been fitted.\n");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we use a different exception type other than ShogunException

SGVector<float64_t> CPruneVarSubMean::apply_to_feature_vector(SGVector<float64_t> vector)
{
float64_t* ret=NULL;
REQUIRE(m_initialized, "Transformer has not been fitted.\n");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we use a different exception type other than ShogunException

Comment thread src/shogun/transformer/Transformer.cpp Outdated
MS_NOT_AVAILABLE);
}

void CTransformer::check_fitted() const

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would rather go with the java like: is_fitted or is_fit depending which english we'd like to go with :) but let's stick to british (non north american english as in case of the exception type naming)

Comment thread src/shogun/transformer/Transformer.cpp Outdated
CTransformer::CTransformer() : CSGObject()
{
SG_ADD(
&m_fitted, "fitted", "Whether the transformer has been fitted.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's register this param as is_fitted

@vigsterkr
vigsterkr merged commit a241ab1 into shogun-toolbox:feature/transformers Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants