// Fit builds the MultiLinearSVC by building n (where n is the number of values
// the singular CategoricalAttribute can take) seperate one-vs-rest models.
761470
func (m *MultiLinearSVC) Fit(instances base.FixedDataGrid) error {
	m.m.Fit(instances)
	return nil
}
809321
func (fv *RawFeatureVector) SerializeSize() int {
	// Find the largest feature bit index
	max := -1
	for feature := range fv.features {
		index := int(feature)
		if index > max {
			max = index
		}
	}
	if max == -1 {
		return 0
	}

	// We calculate byte-length via the largest bit index
	return max/8 + 1
}
781399
func normalize(v reflect.Value) interface{} {
	k := v.Kind()

	switch {
	case isNumber(k):
		f, err := numberToFloat(v)
		if err == nil {
			return f
		}
	}

	return v.Interface()
}
1263420
func (image Image) match(itype InstanceType) imageMatch {
	if !image.matchArch(itype.Arches) {
		return nonMatch
	}
	if itype.VirtType == nil || image.VirtType == *itype.VirtType {
		return exactMatch
	}
	if image.VirtType == "" {
		// Image doesn't specify virtualisation type. We allow it
		// to match, but prefer exact matches.
		return partialMatch
	}
	return nonMatch
}
1288440
func (c *Config) Apply(attrs map[string]interface{}) (*Config, error) {
	defined := c.AllAttrs()
	for k, v := range attrs {
		defined[k] = v
	}
	return New(NoDefaults, defined)
}
614064
func (l *LogLevelType) Matches(v LogLevelType) bool {
	c := l.Value()
	return c&v == v
}
608333
func (a Dimensions) Normalize() (time.Duration, []string) {
	var dur time.Duration
	var tags []string

	for _, dim := range a {
		switch expr := dim.Expr.(type) {
		case *Call:
			lit, _ := expr.Args[0].(*DurationLiteral)
			dur = lit.Val
		case *VarRef:
			tags = append(tags, expr.Val)
		}
	}

	return dur, tags
}
209860
func readSynthdefVariants(r io.Reader, numParams int) ([]*Variant, error) {
	// read number of variants
	var numVariants int16
	if err := binary.Read(r, byteOrder, &numVariants); err != nil {
		return nil, err
	}
	// read variants
	variants := make([]*Variant, numVariants)
	for i := 0; int16(i) < numVariants; i++ {
		v, err := readVariant(r, int32(numParams))
		if err != nil {
			return nil, err
		}
		variants[i] = v
	}
	return variants, nil
}
1335125
func (q *QueryDsl) MultiMatch(s string, fields []string) *QueryDsl {
	q.QueryEmbed.MultiMatch = &MultiMatch{Query: s, Fields: fields}
	return q
}
835743
func (c *AppPackageDeleteCall) Size(size string) *AppPackageDeleteCall {
	c.urlParams_.Set("size", size)
	return c
}
681287
func (p *LinearSVCParams) Copy() *LinearSVCParams {
	ret := &LinearSVCParams{
		p.SolverType,
		nil,
		p.C,
		p.Eps,
		p.WeightClassesAutomatically,
		p.Dual,
	}
	if p.ClassWeights != nil {
		ret.ClassWeights = make([]float64, len(p.ClassWeights))
		copy(ret.ClassWeights, p.ClassWeights)
	}
	return ret
}
632278
func (s *Scheme) Normalize() (err error) {
	tfv := s.t.FreeTypeVar()

	if len(tfv) == 0 {
		return nil
	}

	defer ReturnTypeVarSet(tfv)
	ord := BorrowTypeVarSet(len(tfv))
	for i := range tfv {
		ord[i] = TypeVariable(letters[i])
	}

	s.t, err = s.t.Normalize(tfv, ord)
	s.tvs = ord.Set()
	return
}
90498
func (m *Matrix) Reshape(r, c uint) (*Matrix, error) {
	if r*c != m.Rows*m.Cols {
		return nil, fmt.Errorf("Size is not same")
	}
	row := 0
	col := 0
	newMat := make([][]float32, r)
	for y := 0; y < int(r); y++ {
		newMat[y] = make([]float32, c)
		for x := 0; x < int(c); x++ {
			if col > int(m.Cols)-1 {
				row++
				col = 0
			}
			newMat[y][x] = m.M[row][col]
			col++
		}
	}
	return NewMatrix(newMat), nil
}
451509
func (pca *PCA) Fit(X *mat.Dense) *PCA {
	// Mean to input data
	M := mean(X)
	X = matrixSubVector(X, M)

	// Get SVD decomposition from data
	pca.svd = &mat.SVD{}
	ok := pca.svd.Factorize(X, mat.SVDThin)
	if !ok {
		panic("Unable to factorize")
	}
	if pca.Num_components < 0 {
		panic("Number of components can't be less than zero")
	}

	return pca
}
304618
func (endpointsStrategy) Canonicalize(obj runtime.Object) {
	endpoints := obj.(*api.Endpoints)
	endpoints.Subsets = endptspkg.RepackSubsets(endpoints.Subsets)
}
870066
func Fit(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
	maxW, maxH := width, height

	if maxW <= 0 || maxH <= 0 {
		return &image.NRGBA{}
	}

	srcBounds := img.Bounds()
	srcW := srcBounds.Dx()
	srcH := srcBounds.Dy()

	if srcW <= 0 || srcH <= 0 {
		return &image.NRGBA{}
	}

	if srcW <= maxW && srcH <= maxH {
		return Clone(img)
	}

	srcAspectRatio := float64(srcW) / float64(srcH)
	maxAspectRatio := float64(maxW) / float64(maxH)

	var newW, newH int
	if srcAspectRatio > maxAspectRatio {
		newW = maxW
		newH = int(float64(newW) / srcAspectRatio)
	} else {
		newH = maxH
		newW = int(float64(newH) * srcAspectRatio)
	}

	return Resize(img, newW, newH, filter)
}
977655
func (src Versions) Match(f Filter) (Versions, error) {
	var result Versions
	for _, agent := range src {
		if f.match(agent) {
			result = append(result, agent)
		}
	}
	if len(result) == 0 {
		return nil, ErrNoMatches
	}
	return result, nil
}