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:
parent
2d462da5b3
commit
fab0758198
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user