-
Notifications
You must be signed in to change notification settings - Fork 38
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
PushFixed function for static dataset size #10
base: master
Are you sure you want to change the base?
Changes from 6 commits
d828f7e
416599f
1dae04f
7349d99
4600a11
7a58565
5ea889d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ To capture seasonality, the bootstrap ks test should consider an active window l | |
|
||
### Fence | ||
|
||
The fence test can be configured to use custom `UpperBound` and `LowerBound` values for the fences. If no lower bound is desired, set the value of `LowerBound` to `anomalyzer.NA`. | ||
The fence test can be configured to use custom `UpperBound` and `LowerBound` values for the fences. If no lower bound is desired, set the value of `LowerBound` to the const variable: `anomalyzer.NA`. | ||
|
||
### Diff & Rank | ||
|
||
|
@@ -77,6 +77,14 @@ func main() { | |
// by a call to the Eval method. | ||
prob := anom.Push(8.0) | ||
fmt.Println("Anomalous Probability:", prob) | ||
|
||
// PushFixed method will keep the size of the Data vector constant. | ||
// Oldest data points will be evicted as points are added. | ||
// WARNING: Mixing Push() and PushFixed() will result in failure! | ||
anom2, _ := anomalyzer.NewAnomalyzer(conf, data) | ||
prob2, _ := anom2.PushFixed(8.0) | ||
// returns an error as second value if the array size changed unexpectantly | ||
fmt.Println("Anomalous Probability:", prob2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Indentation here and I think "unexpectantly" -> "unexpectedly" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup! |
||
} | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,18 @@ func (a *Anomalyzer) Push(x float64) float64 { | |
return a.Eval() | ||
} | ||
|
||
// WARNING: Mixing Push() and PushFixed() will result in failure! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, same thing about this comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. woo! I should have caught that.. I think I fixed all this stuff on a separate branch but it's upstream to far to cherry pick cleanly.. |
||
func (a *Anomalyzer) PushFixed(x float64) (float64, error) { | ||
// Add data to fixed size array which will not grow | ||
err := a.Data.PushFixed(x) | ||
if err != nil { | ||
return NA, err | ||
} | ||
|
||
// evaluate the anomalous probability | ||
return a.Eval(), nil | ||
} | ||
|
||
// Return the weighted average of all statistical tests | ||
// for anomaly detection, which yields the probability that | ||
// the currently observed behavior is anomalous. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
Push()
andPushFixed()
no longer conflict, probably should remove this warning and the one below, right before the definition ofPushFixed()
.