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

DTW method realization #517

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from

Conversation

EjenY-Poltavchiny
Copy link

This is my first attempt to merge DTW method to kmath-stat series package. You can find short description in my code. Honestly, I'm doing merge request for the first time, so if I have missed rules of arrangement my apologize.



fun main() {
with(DoubleField.bufferAlgebra.withSize(5)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Examples and tests must be moved to examples package

Copy link
Author

@EjenY-Poltavchiny EjenY-Poltavchiny Jun 13, 2023

Choose a reason for hiding this comment

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

The problem is I cannot run tests from exmaple Execution failed for task ':kmath-symja:compileKotlin', but can run from commonTest.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please merge current dev branch. It is fixed there.

* There is special cases for i = 0 or j = 0.
*/

public fun costMatrix(series1 : DoubleBuffer, series2 : DoubleBuffer) : DoubleBufferND {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it have to be public and top-level?

Copy link
Author

Choose a reason for hiding this comment

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

Moved this into the body of DTW main method.

* for two series comparing and penalty for this alignment.
*/

public fun dynamicTimeWarping(series1 : DoubleBuffer, series2 : DoubleBuffer) : DynamicTimeWarpingData {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method seems to be primary. But it pollutes the global name space. Maybe rename DynamicTimeWarpingData to DynamicTimeWarping and replace this method with a fake constructor (a function with name DynamicTimeWarping)?

Copy link
Author

Choose a reason for hiding this comment

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

Don't understand exactly. I have to remove class DynamicTimeWarpingClass or change this method name?

@SPC-code SPC-code changed the base branch from master to dev June 11, 2023 05:52
Comment on lines 90 to 98
id_x == 0 || costMatrix[id_x, id_y] == costMatrix[id_x, id_y - 1] + abs(series1[id_x] - series2[id_y]) -> {
moveOption(DtwOffset.LEFT)
}
id_y == 0 || costMatrix[id_x, id_y] == costMatrix[id_x - 1, id_y] + abs(series1[id_x] - series2[id_y]) -> {
moveOption(DtwOffset.BOTTOM)
}
costMatrix[id_x, id_y] == costMatrix[id_x - 1, id_y - 1] + abs(series1[id_x] - series2[id_y]) -> {
moveOption(DtwOffset.DIAGONAL)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like equality test for double values. @SPC-code what do you think about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late reply. Equality should not be tested for floating points unless it is magic constants like 0.0.

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 this pull request may close these issues.

3 participants