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

Merge pull request #240 from yaserazfar/check_unchecked_errors

Add error checking for err variables that were being left unchecked
This commit is contained in:
Richard Townsend 2019-12-30 16:12:59 +00:00 committed by GitHub
commit 3e43e74895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 0 deletions

View File

@ -19,6 +19,7 @@ func TestMultiSVMUnweighted(t *testing.T) {
Convey("Predictions should work...", func() {
predictions, err := m.Predict(Y)
So(err, ShouldEqual, nil)
cf, err := evaluation.GetConfusionMatrix(Y, predictions)
So(err, ShouldEqual, nil)
So(evaluation.GetAccuracy(cf), ShouldBeGreaterThan, 0.70)
@ -66,6 +67,7 @@ func TestMultiSVMWeighted(t *testing.T) {
Convey("Predictions should work...", func() {
predictions, err := m.Predict(Y)
So(err, ShouldEqual, nil)
cf, err := evaluation.GetConfusionMatrix(Y, predictions)
So(err, ShouldEqual, nil)
So(evaluation.GetAccuracy(cf), ShouldBeGreaterThan, 0.60)

View File

@ -82,6 +82,7 @@ func TestRandomForestSerialization(t *testing.T) {
Convey("Saving the model should work...", func() {
f, err := ioutil.TempFile(os.TempDir(), "rf")
So(err, ShouldBeNil)
err = rf.Save(f.Name())
defer func() {
f.Close()

View File

@ -261,6 +261,9 @@ func (lr *LinearSVC) SaveWithPrefix(writer *base.ClassifierSerializer, prefix st
}
f, err := ioutil.TempFile(os.TempDir(), "liblinear")
if err != nil {
return err
}
defer func() {
f.Close()
}()

View File

@ -60,6 +60,7 @@ func TestLinearSVC(t *testing.T) {
So(err, ShouldBeNil)
inst, err := base.ParseCSVToInstances("../examples/datasets/iris_headers.csv", true)
So(err, ShouldBeNil)
inst.RemoveClassAttribute(inst.AllAttributes()[4])
inst.AddClassAttribute(inst.AllAttributes()[1])

View File

@ -135,6 +135,7 @@ func TestBaggedModelRandomForestSerialization(t *testing.T) {
Convey("Saving the model should be fine...", func() {
f, err := ioutil.TempFile(os.TempDir(), "rf")
So(err, ShouldBeNil)
defer func() {
f.Close()
}()

View File

@ -52,6 +52,7 @@ func TestOneVsAllModel(t *testing.T) {
predictions, err := m.Predict(Y)
So(err, ShouldEqual, nil)
f, err := ioutil.TempFile(os.TempDir(), "tmpCls")
So(err, ShouldBeNil)
defer func() {
f.Close()
}()

View File

@ -46,6 +46,7 @@ func TestSerialize(t *testing.T) {
Convey("Saving the classifer should work...", func() {
f, err := ioutil.TempFile(os.TempDir(), "nb")
So(err, ShouldBeNil)
defer func() {
f.Close()
}()