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

Merge branch 'master' into issue222

This commit is contained in:
Richard Townsend 2019-03-23 18:34:21 +00:00 committed by GitHub
commit b42867aceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 3 deletions

3
.gitignore vendored
View File

@ -14,3 +14,6 @@
# go test coverprofiles
*.coverprofile
#vim
*.sw*

BIN
knn/temp.cls Normal file

Binary file not shown.

View File

@ -14,7 +14,7 @@ func NewCosine() *Cosine {
// Dot computes dot value of vectorX and vectorY.
func (c *Cosine) Dot(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
subVector := mat.NewDense(0, 0, nil)
subVector := new(mat.Dense)
subVector.MulElem(vectorX, vectorY)
result := mat.Sum(subVector)

View File

@ -27,7 +27,6 @@ func (e *Euclidean) Distance(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
subVector := mat.NewDense(1, 1, nil)
subVector.Reset()
subVector.Sub(vectorX, vectorY)
result := e.InnerProduct(subVector, subVector)
return math.Sqrt(result)

View File

@ -28,7 +28,7 @@ func (p *PolyKernel) InnerProduct(vectorX *mat.Dense, vectorY *mat.Dense) float6
// Distance computes distance under the polynomial kernel (maybe not needed?)
func (p *PolyKernel) Distance(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
subVector := mat.NewDense(0, 0, nil)
subVector := new(mat.Dense)
subVector.Sub(vectorX, vectorY)
result := p.InnerProduct(subVector, subVector)

BIN
trees/tmp Normal file

Binary file not shown.