Title: | Change Points Detection with Spectral Clustering |
---|---|
Description: | Calculate change point based on spectral clustering with the option to automatically calculate the number of clusters if this information is not available. |
Authors: | Luis Uzai [aut, cre] |
Maintainer: | Luis Uzai <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-16 03:18:21 UTC |
Source: | https://github.com/cran/SpecDetec |
Calculate the affinity matrix based on the similarity matrix
calculateAffinityMatrix(similarityMatrix, neighboorsNumber = 2)
calculateAffinityMatrix(similarityMatrix, neighboorsNumber = 2)
similarityMatrix |
Matrix of similarity between all points in the time series |
neighboorsNumber |
Number of neighbors to consider affinity between nodes |
Calculate the affinity matrix based on the similarity matrix If the number of neighbors is equal to or greater than the similarity matrix then the similarity and affinity matrix are equal
Affinity matrix based on the similarity matrix
Luis Gustavo Uzai
Adaptation of the bartlett method of the speccalt package to estimate the number of clusters in the context of spectral clustering to detect change points
clusterEstimatetNumber(eigenvectorValues, tolerance, maxClusterNumber)
clusterEstimatetNumber(eigenvectorValues, tolerance, maxClusterNumber)
eigenvectorValues |
Eigenvector matrix based on the affinity matrix |
tolerance |
approximation to consider valid clusters |
maxClusterNumber |
maximum number of calculable clusters |
Adaptation of the bartlett method of the speccalt package to estimate the number of clusters in the context of spectral clustering to detect change points
An estimated number of clusters
Luis Gustavo Uzai
Converts the time series to position and value matrix
convertToMatrixTimeSeries(data)
convertToMatrixTimeSeries(data)
data |
List of values corresponding to the time series |
Gets a list of values of any size and creates a key and value array of all positions
The key matrix and value of the time series.
Luis Gustavo Uzai
Derivation of RefrigerationDevices of the UCR Time Series Classification Repository These problems were taken from data recorded as part of government sponsored study called Powering the Nation. The intention was to collect behavioural data about how consumers use electricity within the home to help reduce the UK's carbon footprint.
DEVICE1
DEVICE1
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of RefrigerationDevices of the UCR Time Series Classification Repository These problems were taken from data recorded as part of government sponsored study called Powering the Nation. The intention was to collect behavioural data about how consumers use electricity within the home to help reduce the UK's carbon footprint.
DEVICE2
DEVICE2
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of RefrigerationDevices of the UCR Time Series Classification Repository These problems were taken from data recorded as part of government sponsored study called Powering the Nation. The intention was to collect behavioural data about how consumers use electricity within the home to help reduce the UK's carbon footprint.
DEVICE3
DEVICE3
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of RefrigerationDevices of the UCR Time Series Classification Repository These problems were taken from data recorded as part of government sponsored study called Powering the Nation. The intention was to collect behavioural data about how consumers use electricity within the home to help reduce the UK's carbon footprint.
DEVICE4
DEVICE4
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of RefrigerationDevices of the UCR Time Series Classification Repository These problems were taken from data recorded as part of government sponsored study called Powering the Nation. The intention was to collect behavioural data about how consumers use electricity within the home to help reduce the UK's carbon footprint.
DEVICE5
DEVICE5
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of RefrigerationDevices of the UCR Time Series Classification Repository These problems were taken from data recorded as part of government sponsored study called Powering the Nation. The intention was to collect behavioural data about how consumers use electricity within the home to help reduce the UK's carbon footprint.
DEVICE6
DEVICE6
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of Meat of the UCR Time Series Classification Repository Food spectrographs are used in chemometrics to classify food types, a task that has obvious applications in food safety and quality assurance. The classes are chicken, pork and turkey.
FTIR1
FTIR1
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of Meat of the UCR Time Series Classification Repository Food spectrographs are used in chemometrics to classify food types, a task that has obvious applications in food safety and quality assurance. The classes are chicken, pork and turkey.
FTIR2
FTIR2
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of Meat of the UCR Time Series Classification Repository Food spectrographs are used in chemometrics to classify food types, a task that has obvious applications in food safety and quality assurance. The classes are chicken, pork and turkey.
FTIR3
FTIR3
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of Meat of the UCR Time Series Classification Repository Food spectrographs are used in chemometrics to classify food types, a task that has obvious applications in food safety and quality assurance. The classes are chicken, pork and turkey.
FTIR4
FTIR4
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of Meat of the UCR Time Series Classification Repository Food spectrographs are used in chemometrics to classify food types, a task that has obvious applications in food safety and quality assurance. The classes are chicken, pork and turkey.
FTIR5
FTIR5
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Derivation of Meat of the UCR Time Series Classification Repository Food spectrographs are used in chemometrics to classify food types, a task that has obvious applications in food safety and quality assurance. The classes are chicken, pork and turkey.
FTIR6
FTIR6
The format is: Value Class 1.063400 1 -0.953410 1 ... -0.596090 2 ...
Measure of similarity between two points represented by x1 and x2
gaussianKernel(x1, x2, alpha = 1)
gaussianKernel(x1, x2, alpha = 1)
x1 |
first valor to computate |
x2 |
second valor to computate |
alpha |
Alpha Measure |
Measure of similarity between two points represented by x1 and x2
Measure of similarity between two points.
Luis Gustavo Uzai
Calculate the eigenvector of the affinity matrix
generateEigenvectorMatrix(affinityMatrix)
generateEigenvectorMatrix(affinityMatrix)
affinityMatrix |
Affinity matrix based on the similarity matrix based on key and value matrix of the time series |
Calculates the laplacian matrix based on the affinity matrix and calculates the auto values of the graph with the eigen function
Eigenvector matrix based on the affinity matrix
Luis Gustavo Uzai
Use some similarity measure to calculate the similarity matrix
generateSimilarityMatrix(data, similarityMeasure)
generateSimilarityMatrix(data, similarityMeasure)
data |
Key and value matrix of a time series |
similarityMeasure |
Measure of similarity between two points represented by x1 and x2 |
Use some similarity measure to calculate the similarity matrix
Matrix of similarity calculated from the key and value matrix.
Luis Gustavo Uzai
Get the Factor of the cluster position in relation to the matrix of eigenvectors
getClusterFact(eigenvectorValues, eigenvectorLengthLessOne, clusterNumber, reverseClusterNumber)
getClusterFact(eigenvectorValues, eigenvectorLengthLessOne, clusterNumber, reverseClusterNumber)
eigenvectorValues |
Eigenvector matrix based on the affinity matrix |
eigenvectorLengthLessOne |
the eigenvector matrix size minus 1 |
clusterNumber |
the cluster position number being tested |
reverseClusterNumber |
the number of the inverse position of the cluster being tested |
Gets the factor of the value and its opposite in relation to the matrix of the eigenvectors
Factor of the cluster position in relation to the matrix of eigenvectors
Luis Gustavo Uzai
Get the Product of the cluster position in relation to the matrix of eigenvectors
getClusterProd(eigenvectorValues, eigenvectorLengthLessOne, clusterNumber, reverseClusterNumber)
getClusterProd(eigenvectorValues, eigenvectorLengthLessOne, clusterNumber, reverseClusterNumber)
eigenvectorValues |
Eigenvector matrix based on the affinity matrix |
eigenvectorLengthLessOne |
the eigenvector matrix size minus 1 |
clusterNumber |
the cluster position number being tested |
reverseClusterNumber |
the number of the inverse position of the cluster being tested |
Gets the product of the value and its opposite in relation to the matrix of the eigenvectors
Product of the cluster position in relation to the matrix of eigenvectors
Luis Gustavo Uzai
Clustering with the smallest eigenvectors from eigenvector Matrix
getSpectralClusters(eigenvectorMatrix, numberOfClusters = 2)
getSpectralClusters(eigenvectorMatrix, numberOfClusters = 2)
eigenvectorMatrix |
Eigenvector matrix based on the affinity matrix |
numberOfClusters |
maximum number of clusters for prediction |
Modified standard function present in kernlab to perform clustering with graph spectrum using standard version of K-Means
K-Means Cluster Object
Luis Gustavo Uzai
Calculate change point based on spectral clustering you have the option to automatically calculate the number of clusters if this information is not available
Spec(data, neighboorsNumber = 5, tolerance = 0.01, maxNumberOfChangePoints = 19, estimationChangePointsNumber = NULL)
Spec(data, neighboorsNumber = 5, tolerance = 0.01, maxNumberOfChangePoints = 19, estimationChangePointsNumber = NULL)
data |
List of values corresponding to the time series |
neighboorsNumber |
Number of neighbors to consider affinity between nodes |
tolerance |
approximation to consider valid clusters, used only for calculation of forecast of change points, default 0.01 |
maxNumberOfChangePoints |
maximum number of clusters for prediction : default 19 |
estimationChangePointsNumber |
predicted number of change points in the series, if null, is automatically calculated: default null |
Calculate change point based on spectral clustering you have the option to automatically calculate the number of clusters if this information is not available. It uses the Gaussian Kernel for the calculation of affinity matrix and Kmeans for the spectral cluster, however, several other options can be used and the package must be customized to better suit the use.
Numerical array with the position of the change points in the time series
Luis Gustavo Uzai
data <- DEVICE1[, 1] realChangePoints <- c(which(diff(DEVICE1$Class) != 0)) calculateChangePoints <- Spec(data, neighboorsNumber = 6, tolerance = 0.005, estimationChangePointsNumber = 2) minValue <- -99999 maxValue <- 99999 plot(data, type = "l", xlab = "x", ylab = "y") for (r in 1:length(realChangePoints)) { lines(x = c(realChangePoints[r], realChangePoints[r]), y = c(minValue, maxValue), lwd = 2, col = "red") } for (n in 1:length(calculateChangePoints)) { lines(x = c(calculateChangePoints[n], calculateChangePoints[n]), y = c(minValue, maxValue), lwd = 2, col = "blue") }
data <- DEVICE1[, 1] realChangePoints <- c(which(diff(DEVICE1$Class) != 0)) calculateChangePoints <- Spec(data, neighboorsNumber = 6, tolerance = 0.005, estimationChangePointsNumber = 2) minValue <- -99999 maxValue <- 99999 plot(data, type = "l", xlab = "x", ylab = "y") for (r in 1:length(realChangePoints)) { lines(x = c(realChangePoints[r], realChangePoints[r]), y = c(minValue, maxValue), lwd = 2, col = "red") } for (n in 1:length(calculateChangePoints)) { lines(x = c(calculateChangePoints[n], calculateChangePoints[n]), y = c(minValue, maxValue), lwd = 2, col = "blue") }