-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from shapelets/feature/clustering
Adding clustering functions and tests
- Loading branch information
Showing
40 changed files
with
2,040 additions
and
1,928 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2018 Shapelets.io | ||
# Copyright (c) 2019 Shapelets.io | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
mvn dokka:dokka | ||
mvn test | ||
mvn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,4 +80,4 @@ Start a new docker container. | |
``` | ||
# Start docker | ||
docker run --rm -ti shapelets/khiva-java | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2019 Shapelets.io | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
*/ | ||
|
||
package io.shapelets.khiva | ||
|
||
/** | ||
* Khiva Clustering class containing several clustering methods. | ||
*/ | ||
object Clustering : Library() { | ||
@JvmStatic | ||
private external fun kMeans(tss: Long, k: Int, tolerance: Float, maxInterations: Int): LongArray | ||
|
||
@JvmStatic | ||
private external fun kShape(tss: Long, k: Int, tolerance: Float, maxInterations: Int): LongArray | ||
|
||
/** | ||
* Calculates the KMeans algorithm. | ||
* | ||
* [1] S. Lloyd. 1982. Least squares quantization in PCM. IEEE Transactions on Information Theory, 28, 2, | ||
* Pages 129-137. | ||
* | ||
* @param tss The set of time series to be clusterized. | ||
* @param k The number of centroids. | ||
* @param tolerance The maximum error tolerance. | ||
* @param maxIterations The maximum number of iterations. | ||
* | ||
* @return An Array of arrays with the resulting centroids and labels. | ||
*/ | ||
fun kMeans(tss: Array, k: Int, tolerance: Float, maxInterations: Int): kotlin.Array<Array> { | ||
val refs = Clustering.kMeans(tss.reference, k, tolerance, maxInterations) | ||
tss.reference = refs[0] | ||
return arrayOf(Array(refs[1]), Array(refs[2])) | ||
} | ||
|
||
/** | ||
* Calculates the KShape algorithm. | ||
* | ||
* [1] John Paparrizos and Luis Gravano. 2016. k-Shape: Efficient and Accurate Clustering of Time Series. | ||
* SIGMOD Rec. 45, 1 (June 2016), 69-76. | ||
* | ||
* @param tss The set of time series to be clusterized. | ||
* @param k The number of centroids. | ||
* @param tolerance The maximum error tolerance. | ||
* @param maxIterations The maximum number of iterations. | ||
* | ||
* @return An Array of arrays with the resulting centroids and labels. | ||
*/ | ||
fun kShape(tss: Array, k: Int, tolerance: Float, maxInterations: Int): kotlin.Array<Array>{ | ||
val refs = Clustering.kShape(tss.reference, k, tolerance, maxInterations) | ||
tss.reference = refs[0] | ||
return arrayOf(Array(refs[1]), Array(refs[2])) | ||
} | ||
} |
Oops, something went wrong.