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

Modify StepFit metric to be RMSE #72

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions perf/go/stepfit/stepfit.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ func GetStepFitAtMid(trace []float32, stddevThreshold float32, interesting float
}
regression = stepSize
}
} else if stepDetection == types.RatioStep {
// This is a modified version of Original Step, which uses
// Root-Mean-Squared Error to calculate the fitness.
lse = float32(math.MaxFloat32)
if y0 != y1 {
d := vec32.SSE(trace[:i], y0) + vec32.SSE(trace[i:], y1)
if d < lse {
lse = d
stepSize = (y0 - y1)
}
}
// Calculate the Root-Mean-Squared Error to measure fit to step function
lse = float32(math.Sqrt(float64(lse) / float64(len(trace))))
if lse < stddevThreshold {
regression = stepSize / stddevThreshold
} else {
regression = stepSize / lse
}
} else /* types.MannWhitneyU */ {
s1 := vec32.ToFloat64(trace[:i])
s2 := vec32.ToFloat64(trace[i:])
Expand Down
4 changes: 4 additions & 0 deletions perf/go/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const (
// empty string so we pick up the right default from old alerts.
OriginalStep StepDetection = ""

// RatioStep is exactly like OriginalStep except it uses RMSE as the
// fitness function to calculate the regression ratio.
RatioStep StepDetection = "ratio"

// AbsoluteStep is a step detection that looks for an absolute magnitude
// change.
AbsoluteStep StepDetection = "absolute"
Expand Down