Skip to content

Commit 5124a4e

Browse files
committed
updated json naming for pmp, kmp, mp
1 parent 266fc99 commit 5124a4e

File tree

5 files changed

+45
-45
lines changed

5 files changed

+45
-45
lines changed

av/annotation_vector.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
"github.com/matrix-profile-foundation/go-matrixprofile/util"
1212
)
1313

14-
type AV int
14+
type AV string
1515

1616
const (
17-
Default = iota // Default is the default annotation vector of all ones
18-
Complexity // Complexity is the annotation vector that focuses on areas of high "complexity"
19-
MeanStd // MeanStd is the annotation vector focusing on areas where the signal is within a standard deviation of the mean
20-
Clipping // Clipping is the annotation vector reducing the importance of areas showing clipping effects on the positive and negative regime
17+
Default AV = "default" // Default is the default annotation vector of all ones
18+
Complexity AV = "complexity" // Complexity is the annotation vector that focuses on areas of high "complexity"
19+
MeanStd AV = "mean_std" // MeanStd is the annotation vector focusing on areas where the signal is within a standard deviation of the mean
20+
Clipping AV = "clipping" // Clipping is the annotation vector reducing the importance of areas showing clipping effects on the positive and negative regime
2121
)
2222

2323
// Create returns the annotation vector given an input time series and a window size m
@@ -33,7 +33,7 @@ func Create(av AV, ts []float64, m int) ([]float64, error) {
3333
case Clipping:
3434
avec = makeClipping(ts, m)
3535
default:
36-
return nil, fmt.Errorf("invalid annotation vector specified with matrix profile, %d", av)
36+
return nil, fmt.Errorf("invalid annotation vector specified with matrix profile, %s", av)
3737
}
3838
return avec, nil
3939
}

kmp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func TestKMPSave(t *testing.T) {
200200
m := 3
201201
p, err := NewKMP(ts, m)
202202
p.Compute()
203-
filepath := "./mp.json"
203+
filepath := "./kmp.json"
204204
err = p.Save(filepath, "json")
205205
if err != nil {
206206
t.Errorf("Received error while saving matrix profile, %v", err)
@@ -215,7 +215,7 @@ func TestKMPLoad(t *testing.T) {
215215
m := 3
216216
p, err := NewKMP(ts, m)
217217
p.Compute()
218-
filepath := "./mp.json"
218+
filepath := "./kmp.json"
219219
if err = p.Save(filepath, "json"); err != nil {
220220
t.Errorf("Received error while saving matrix profile, %v", err)
221221
}

matrixprofile.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ import (
2626
// for a given timeseries of length N and subsequence length of M. The profile
2727
// and the profile index are stored here.
2828
type MatrixProfile struct {
29-
A []float64 // query time series
30-
B []float64 // timeseries to perform full join with
31-
AMean []float64 // sliding mean of a with a window of m each
32-
AStd []float64 // sliding standard deviation of a with a window of m each
33-
BMean []float64 // sliding mean of b with a window of m each
34-
BStd []float64 // sliding standard deviation of b with a window of m each
35-
BF []complex128 // holds an existing calculation of the FFT of b timeseries
36-
N int // length of the timeseries
37-
M int // length of a subsequence
38-
SelfJoin bool // indicates whether a self join is performed with an exclusion zone
39-
MP []float64 // matrix profile
40-
Idx []int // matrix profile index
41-
MPB []float64 // matrix profile for the BA join
42-
IdxB []int // matrix profile index for the BA join
43-
AV av.AV // type of annotation vector which defaults to all ones
44-
Opts *MPOptions // options used for the computation
29+
A []float64 `json:"a"` // query time series
30+
B []float64 `json:"b"` // timeseries to perform full join with
31+
AMean []float64 `json:"a_mean"` // sliding mean of a with a window of m each
32+
AStd []float64 `json:"a_std"` // sliding standard deviation of a with a window of m each
33+
BMean []float64 `json:"b_mean"` // sliding mean of b with a window of m each
34+
BStd []float64 `json:"b_std"` // sliding standard deviation of b with a window of m each
35+
BF []complex128 `json:"b_fft"` // holds an existing calculation of the FFT of b timeseries
36+
N int `json:"n"` // length of the timeseries
37+
M int `json:"w"` // length of a subsequence
38+
SelfJoin bool `json:"self_join"` // indicates whether a self join is performed with an exclusion zone
39+
MP []float64 `json:"mp"` // matrix profile
40+
Idx []int `json:"pi"` // matrix profile index
41+
MPB []float64 `json:"mp_ba"` // matrix profile for the BA join
42+
IdxB []int `json:"pi_ba"` // matrix profile index for the BA join
43+
AV av.AV `json:"annotation_vector"` // type of annotation vector which defaults to all ones
44+
Opts *MPOptions `json:"options"` // options used for the computation
4545
}
4646

4747
// New creates a matrix profile struct with a given timeseries length n and
@@ -283,19 +283,19 @@ func MPDist(a, b []float64, m int, o *MPOptions) (float64, error) {
283283
type Algo string
284284

285285
const (
286-
AlgoSTOMP Algo = "STOMP"
287-
AlgoSTAMP Algo = "STAMP"
288-
AlgoSTMP Algo = "STMP"
289-
AlgoMPX Algo = "MPX"
286+
AlgoSTOMP Algo = "stomp"
287+
AlgoSTAMP Algo = "stamp"
288+
AlgoSTMP Algo = "stmp"
289+
AlgoMPX Algo = "mpx"
290290
)
291291

292292
// MPOptions are parameters to vary the algorithm to compute the matrix profile.
293293
type MPOptions struct {
294-
Algorithm Algo // choose which algorithm to compute the matrix profile
295-
Sample float64 // only applicable to algorithm STAMP
296-
Parallelism int
297-
Euclidean bool // defaults to using euclidean distance instead of pearson correlation for matrix profile
298-
RemapNegCorr bool // defaults to no remapping. This is used so that highly negatively correlated sequences will show a low distance as well.
294+
Algorithm Algo `json:"algorithm"` // choose which algorithm to compute the matrix profile
295+
Sample float64 `json:"sample_pct"` // only applicable to algorithm STAMP
296+
Parallelism int `json:"parallelism"`
297+
Euclidean bool `json:"euclidean"` // defaults to using euclidean distance instead of pearson correlation for matrix profile
298+
RemapNegCorr bool `json:"remap_negative_correlation"` // defaults to no remapping. This is used so that highly negatively correlated sequences will show a low distance as well.
299299
}
300300

301301
// NewMPOpts returns a default MPOptions

pmp.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import (
1313

1414
// PMP represents the pan matrix profile
1515
type PMP struct {
16-
A []float64 // query time series
17-
B []float64 // timeseries to perform full join with
18-
SelfJoin bool // indicates whether a self join is performed with an exclusion zone
19-
PMP [][]float64 // pan matrix profile
20-
PIdx [][]int // pan matrix profile index
21-
PWindows []int // pan matrix windows used and is aligned with PMP and PIdx
22-
Opts *PMPOptions // options used for the computation
16+
A []float64 `json:"a"` // query time series
17+
B []float64 `json:"b"` // timeseries to perform full join with
18+
SelfJoin bool `json:"self_join"` // indicates whether a self join is performed with an exclusion zone
19+
PMP [][]float64 `json:"pmp"` // pan matrix profile
20+
PIdx [][]int `json:"ppi"` // pan matrix profile index
21+
PWindows []int `json:"windows"` // pan matrix windows used and is aligned with PMP and PIdx
22+
Opts *PMPOptions `json:"options"` // options used for the computation
2323
}
2424

2525
// NewPMP creates a new Pan matrix profile
@@ -90,9 +90,9 @@ func (p *PMP) Load(filepath, format string) error {
9090

9191
// PMPOptions are parameters to vary the algorithm to compute the pan matrix profile.
9292
type PMPOptions struct {
93-
LowerM int // used for pan matrix profile
94-
UpperM int // used for pan matrix profile
95-
MPOpts *MPOptions
93+
LowerM int `json:"lower_m"` // used for pan matrix profile
94+
UpperM int `json:"upper_m"` // used for pan matrix profile
95+
MPOpts *MPOptions `json:"mp_options"`
9696
}
9797

9898
// NewPMPOpts returns a default PMPOptions

pmp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func TestPMPSave(t *testing.T) {
1010
ts := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
1111
p, err := NewPMP(ts, nil)
1212
p.Compute(NewPMPOpts(3, 5))
13-
filepath := "./mp.json"
13+
filepath := "./pmp.json"
1414
err = p.Save(filepath, "json")
1515
if err != nil {
1616
t.Errorf("Received error while saving matrix profile, %v", err)
@@ -24,7 +24,7 @@ func TestPMPLoad(t *testing.T) {
2424
ts := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
2525
p, err := NewPMP(ts, nil)
2626
p.Compute(NewPMPOpts(3, 5))
27-
filepath := "./mp.json"
27+
filepath := "./pmp.json"
2828
if err = p.Save(filepath, "json"); err != nil {
2929
t.Errorf("Received error while saving matrix profile, %v", err)
3030
}

0 commit comments

Comments
 (0)