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:
commit
3e43e74895
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
}()
|
||||
|
@ -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])
|
||||
|
||||
|
@ -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()
|
||||
}()
|
||||
|
@ -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()
|
||||
}()
|
||||
|
@ -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()
|
||||
}()
|
||||
|
Loading…
x
Reference in New Issue
Block a user