示例#1
0
// NewFullTrace takes data you would find in a Trace and returns a
// ClusterableTrace usable for kmeans clustering.
func NewFullTrace(key string, values []float64, params map[string]string, minStdDev float64) *ClusterableTrace {
	norm := make([]float64, len(values))

	copy(norm, values)
	vec.Fill(norm)
	vec.Norm(norm, minStdDev)

	return &ClusterableTrace{
		Key:    key,
		Values: norm,
		Params: params,
	}
}
示例#2
0
// fillFunc implements Func and fills in all the missing datapoints with nearby
// points.
//
// Note that a Trace with all MISSING_DATA_SENTINEL values will be filled with
// 0's.
func (FillFunc) Eval(ctx *Context, node *Node) ([]*types.PerfTrace, error) {
	if len(node.Args) != 1 {
		return nil, fmt.Errorf("fill() takes a single argument.")
	}
	if node.Args[0].Typ != NodeFunc {
		return nil, fmt.Errorf("fill() takes a function argument.")
	}
	traces, err := node.Args[0].Eval(ctx)
	if err != nil {
		return nil, fmt.Errorf("fill() failed evaluating argument: %s", err)
	}

	for _, tr := range traces {
		vec.Fill(tr.Values)
	}
	return traces, nil
}