mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-30 13:48:57 +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
|
# go test coverprofiles
|
||||||
*.coverprofile
|
*.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.
|
// Dot computes dot value of vectorX and vectorY.
|
||||||
func (c *Cosine) Dot(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
|
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)
|
subVector.MulElem(vectorX, vectorY)
|
||||||
result := mat.Sum(subVector)
|
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 := mat.NewDense(1, 1, nil)
|
||||||
subVector.Reset()
|
subVector.Reset()
|
||||||
subVector.Sub(vectorX, vectorY)
|
subVector.Sub(vectorX, vectorY)
|
||||||
|
|
||||||
result := e.InnerProduct(subVector, subVector)
|
result := e.InnerProduct(subVector, subVector)
|
||||||
|
|
||||||
return math.Sqrt(result)
|
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?)
|
// Distance computes distance under the polynomial kernel (maybe not needed?)
|
||||||
func (p *PolyKernel) Distance(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
|
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)
|
subVector.Sub(vectorX, vectorY)
|
||||||
result := p.InnerProduct(subVector, subVector)
|
result := p.InnerProduct(subVector, subVector)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user