1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-05-03 22:17:14 +08:00
golearn/naive/bernoulli_nb_test.go
Thiago Cardoso 0035dd184e Bernoulli Naive Bayes: first draft
This is the first draft of the bernoulli naive bayes implementation. It
is missing the Fit function tests and the Predict function.
2014-05-11 21:00:28 -03:00

25 lines
508 B
Go

package naive
import (
"testing"
"github.com/gonum/matrix/mat64"
)
// Test if panic is correctly called when matrices with different
// dimensions are used as arguments.
func TestFitPanic(t *testing.T) {
defer func() {
if recover() == nil {
t.Fatalf("invalid matrix dim did not panic")
}
}()
nb := NewBernoulliNBClassifier(2)
X := mat64.NewDense(10, 20, nil)
// simulating user mistake, one extra label
y := make([]int, 11)
nb.Fit(X, y)
}