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

metrics: Fix TestPolyKernel

This commit is contained in:
Richard Townsend 2016-09-28 15:12:32 +01:00 committed by GitHub
parent 2d462da5b3
commit fab0758198

View File

@ -18,9 +18,10 @@ func NewPolyKernel(degree int) *PolyKernel {
// InnerProduct computes the inner product through a kernel trick
// K(x, y) = (x^T y + 1)^d
func (p *PolyKernel) InnerProduct(vectorX *mat64.Dense, vectorY *mat64.Dense) float64 {
subVector := mat64.NewDense(0, 0, nil)
subVector.MulElem(vectorX, vectorY)
result := mat64.Sum(subVector)
subVectorX := vectorX.ColView(0)
subVectorY := vectorY.ColView(0)
result := mat64.Dot(subVectorX, subVectorY)
result = math.Pow(result+1, float64(p.degree))
return result
}