Changing distance calculation
This commit is contained in:
parent
83daa6a848
commit
afc12aaaf2
6
util.go
6
util.go
@ -69,14 +69,14 @@ func fixModes(modes map[string]string) modeMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func distance(features1 featureMap, features2 featureMap) float64 {
|
func distance(features1 featureMap, features2 featureMap) float64 {
|
||||||
var sum float64
|
var result float64
|
||||||
|
|
||||||
for key, value1 := range features1 {
|
for key, value1 := range features1 {
|
||||||
value2, _ := features2[key]
|
value2, _ := features2[key]
|
||||||
sum += math.Pow(value1-value2, 2)
|
result += 1 - math.Abs(value1-value2)
|
||||||
}
|
}
|
||||||
|
|
||||||
return math.Sqrt(sum)
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func compare(features1 featureMap, features2 featureMap, modes modeMap) float64 {
|
func compare(features1 featureMap, features2 featureMap, modes modeMap) float64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user