Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing terms on C3 linearity check inplementation #585

Closed
eduardojlbatista opened this issue Nov 13, 2019 · 2 comments · Fixed by #590
Closed

Missing terms on C3 linearity check inplementation #585

eduardojlbatista opened this issue Nov 13, 2019 · 2 comments · Fixed by #590

Comments

@eduardojlbatista
Copy link

Good day sir. I've been testing your library for feature selection and have been excited with the ideas presented. However, while scanning through the docummentation of the C3 feature calculator I noticed an error on the algorythm. While you present it as a mean of the lag operator in the form of "E[L^2(X)^2*L(X)*X]", while coding there's a missing square on the formulation. I attached some examples I tried to check if I wasn't mistake. Hope it helps! Thank you very much for your hard work!

  1. Windows
  2. Tsfresh version 0.12.0
  3. x = pd.Series([1, 1, 6, 9, 5, 4, 1, 2])

lag = 2
np.mean((_roll(x, 2 * -lag) * _roll(x, -lag) * x)[0:(n - 2 * lag)])
np.mean((x**2) * x.shift(periods=lag) * x.shift(periods = 2*lag))

  1. From the formulation I was expecting that, for a simple example like the series t, the resulting value would be 117 but, instead got 42. I compared it with my own implementation of the formula, which I thought was somewhat clearer. Hope you can check it and, if it's wrong, fix it.

Thank you very much!

@dbarbier
Copy link
Contributor

My understanding is that code is right but there are 2 errors in docstring, i should start from 1 and square exponentiation must be removed, ie:

 C3 = \mathbb{E}[L^2(X) \cdot L(X) \cdot X] = \frac{1}{n-2lag} \sum_{i=1}^{n-2lag} x_{i + 2 \cdot lag} \cdot x_{i + lag} \cdot x_{i}

@nils-braun
Copy link
Collaborator

@dbarbier or @eduardojlbatista Do you want to supply a PR to fix this docstring issue? Thanks!

dbarbier added a commit to dbarbier/tsfresh that referenced this issue Nov 17, 2019
There were two issues:
 * sum index should start from 1 and not 0
 * x[i+2*lag] should not be squared

Fix blue-yonder#585.
MaxBenChrist pushed a commit that referenced this issue Nov 28, 2019
There were two issues:
 * sum index should start from 1 and not 0
 * x[i+2*lag] should not be squared

Fix #585.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants