Skip to content

Commit

Permalink
using Base.Test for tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
innerlee committed Sep 25, 2016
1 parent cd5c90b commit 618b160
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
using LIBLINEAR
using Base.Test

# computation validation
iris = readcsv(joinpath(dirname(@__FILE__), "iris.csv"))
labels = iris[:, 5]
instances = convert(Matrix{Float64}, iris[:, 1:4]')

model = linear_train(labels[1:2:end], instances[:, 1:2:end]; verbose=true, solver_type=Cint(0))
gc()
(class, decvalues) = linear_predict(model, instances[:, 2:2:end], verbose=true)
correct = Bool[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]
@assert (class .== labels[2:2:end]) == correct
@test (class .== labels[2:2:end]) == correct
println("pass 1.")

model = linear_train(labels[1:2:end], sparse(instances[:, 1:2:end]); verbose=true, solver_type=Cint(0))
gc()
(class, decvalues) = linear_predict(model, sparse(instances[:, 2:2:end]), verbose=true)
correct = Bool[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]
@assert (class .== labels[2:2:end]) == correct
@test (class .== labels[2:2:end]) == correct
println("pass 2.")

# # test bias
# model = linear_train(labels[1:2:end], instances[:, 1:2:end]; verbose=true, solver_type=Cint(0))
# gc()

0 comments on commit 618b160

Please sign in to comment.