예제 #1
0
// AROWClassify classifies the input using the given model having stateName.
func AROWClassify(ctx *core.Context, stateName string, featureVector data.Map) (data.Map, error) {
	s, err := lookupAROWState(ctx, stateName)
	if err != nil {
		return nil, err
	}

	scores, err := s.arow.Classify(FeatureVector(featureVector))
	return data.Map(scores), err
}
예제 #2
0
func (v FeatureVector) toNNFV() (nearest.FeatureVector, error) {
	ret := make(nearest.FeatureVector, 0, len(v))
	err := nested.Flatten(data.Map(v), func(key string, value float32) {
		ret = append(ret, nearest.FeatureElement{Dim: key, Value: value})
	})
	if err != nil {
		return nil, err
	}
	return ret, nil
}
예제 #3
0
func (v FeatureVector) toInternal() (fVector, error) {
	ret := make(fVector, 0, len(v))
	err := nested.Flatten(data.Map(v), func(key string, value float32) {
		ret = append(ret, fElement{dim: dim(key), value: value})
	})
	if err != nil {
		return nil, err
	}
	return ret, nil
}
예제 #4
0
파일: arow.go 프로젝트: sensorbee/jubatus
// toInternal converts a feature vector to internal format. It requires write lock for intern.
func (v FeatureVector) toInternal(intern *intern.Intern) (fVectorForScores, fVector, error) {
	full := make(fVector, 0, len(v))
	err := nested.Flatten(data.Map(v), func(key string, value float32) {
		full = append(full, fElement{dim(intern.Get(key)), value})
	})
	if err != nil {
		return nil, nil, err
	}
	return fVectorForScores(full), full, nil
}
예제 #5
0
파일: arow.go 프로젝트: sensorbee/jubatus
// toInternalForScores converts a feature vector to internal format. It requires read lock for intern.
func (v FeatureVector) toInternalForScores(intern *intern.Intern) (fVectorForScores, error) {
	ret := make(fVectorForScores, 0, len(v))
	err := nested.Flatten(data.Map(v), func(key string, value float32) {
		if d := intern.GetOrZero(key); d != 0 {
			ret = append(ret, fElement{dim(d), value})
		}
	})
	if err != nil {
		return nil, err
	}
	return ret, nil
}