1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-26 13:49:14 +08:00

go fmt cosine.go

This commit is contained in:
FrozenKP 2017-04-07 21:28:56 +08:00
parent 8d0ce56382
commit 3a5e314911

View File

@ -24,11 +24,11 @@ func (c *Cosine) Dot(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
// Distance computes Cosine distance.
// It will return distance which represented as 1-cos() (ranged from 0 to 2).
func (c *Cosine) Distance(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
dotXY := c.Dot(vectorX, vectorY)
lengthX := math.Sqrt(c.Dot(vectorX, vectorX))
lengthY := math.Sqrt(c.Dot(vectorY, vectorY))
dotXY := c.Dot(vectorX, vectorY)
lengthX := math.Sqrt(c.Dot(vectorX, vectorX))
lengthY := math.Sqrt(c.Dot(vectorY, vectorY))
cos := dotXY / (lengthX*lengthY)
cos := dotXY / (lengthX * lengthY)
return 1-cos
return 1 - cos
}