1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-25 13:48:49 +08:00
golearn/metrics/pairwise/rbf_kernel_test.go
2018-06-16 22:11:59 +08:00

29 lines
605 B
Go

package pairwise
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
"gonum.org/v1/gonum/mat"
)
func TestRBFKernel(t *testing.T) {
var vectorX, vectorY *mat.Dense
rbfKernel := NewRBFKernel(0.1)
Convey("Given two vectors", t, func() {
vectorX = mat.NewDense(3, 1, []float64{1, 2, 3})
vectorY = mat.NewDense(3, 1, []float64{2, 4, 5})
Convey("When doing inner product", func() {
result := rbfKernel.InnerProduct(vectorX, vectorY)
Convey("The result should almost equal 0.4065696597405991", func() {
So(result, ShouldAlmostEqual, 0.4065696597405991)
})
})
})
}