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:
commit
b42867aceb
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,3 +14,6 @@
|
||||
|
||||
# go test coverprofiles
|
||||
*.coverprofile
|
||||
|
||||
#vim
|
||||
*.sw*
|
||||
|
BIN
knn/temp.cls
Normal file
BIN
knn/temp.cls
Normal file
Binary file not shown.
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user