Skip to content

Commit

Permalink
artifact more
Browse files Browse the repository at this point in the history
  • Loading branch information
sevarvv committed Jul 2, 2021
1 parent 9d59748 commit 484d1cc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 47 deletions.
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LIBLINEAR = "2d691ee1-e668-5016-a719-b2531b85e0f5"
libsvm_jll = "08558c22-525a-5d2a-acf6-0ac6658ffce4"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"

[compat]
LIBLINEAR = "0.5, 0.6"
LIBLINEAR = "0.6, 0.7"
DocumentFunction = "1"
Suppressor = "0.2, 0.3"
libsvm_jll = "3"
julia = "1.6"

[extras]
Expand Down
2 changes: 2 additions & 0 deletions src/SVR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import Libdl
import DelimitedFiles
import DocumentFunction
import Statistics
import Suppressor
import libsvm_jll
import LIBLINEAR

include("SVRconstants.jl")
include("SVRlib.jl")
Expand Down
3 changes: 2 additions & 1 deletion src/SVRfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function train(y::AbstractVector{Float64}, x::AbstractArray{Float64}; svm_type::
param = mapparam(; svm_type=svm_type, kernel_type=kernel_type, degree=degree, gamma=gamma, coef0=coef0, C=C, nu=nu, epsilon=epsilon, cache_size=cache_size, tolerance=tol, shrinking=shrinking, probability=probability)
nodes, nodeptrs = mapnodes(x)
prob = svm_problem(length(a), pointer(a), pointer(nodeptrs))
plibsvmmodel = ccall((:svm_train, libsvm_jll.libsvm), Ptr{svm_model}, (Ptr{svm_problem}, Ptr{svm_parameter}), pointer_from_objref(prob), pointer_from_objref(param))
local plibsvmmodel
@Suppressor.suppress (plibsvmmodel = ccall((:svm_train, libsvm_jll.libsvm), Ptr{svm_model}, (Ptr{svm_problem}, Ptr{svm_parameter}), pointer_from_objref(prob), pointer_from_objref(param)))
return svmmodel(plibsvmmodel, param, prob, nodes)
end
function train(y::AbstractVector, x::AbstractArray; kw...)
Expand Down
45 changes: 0 additions & 45 deletions src/SVRlib.jl
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
"""
catch lib output
$(DocumentFunction.documentfunction(liboutput; argtext=Dict("str"=>"string")))
"""
function liboutput(str::Ptr{UInt8})
if verbosity
print(unsafe_string(str))
end
nothing
end

# get library
let libsvm = C_NULL
global get_lib
function get_lib()
if libsvm == C_NULL
libpath = joinpath(dirname(@__FILE__), "..", "deps", "libsvm-3.22")
libfile = joinpath(libpath, "libsvm.so.2")
libsvm = Libdl.dlopen(libfile)
ccall(Libdl.dlsym(libsvm, :svm_set_print_string_function), Nothing, (Ptr{Nothing},), @cfunction(liboutput, Nothing, (Ptr{UInt8},)))
end
libsvm
end
end

# make lib function calls
macro cachedsym(symname::Symbol)
cached = gensym()
quote
let $cached = C_NULL
global ($symname)
($symname)() = ($cached) == C_NULL ?
($cached = Libdl.dlsym(get_lib(), $(string(symname)))) :
$cached
end
end
end

@cachedsym svm_train
@cachedsym svm_predict
@cachedsym svm_save_model
@cachedsym svm_load_model
@cachedsym svm_free_model_content

"""
$(DocumentFunction.documentfunction(mapparam;
keytext=Dict("svm_type"=>"SVM type [default=`EPSILON_SVR`]",
Expand Down

2 comments on commit 484d1cc

@montyvesselinov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/40396

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.0 -m "<description of version>" 484d1cc33fa063c53feb021ec5ebe735abc93496
git push origin v1.2.0

Please sign in to comment.