LIBSVM.svmmodelMethod

Convert SVM model to libsvm struct for prediction

LIBSVM.svmpredictMethod

svmpredict{T,U<:Real}(model::SVM{T}, X::AbstractMatrix{U})

Predict values using model based on data X. The shape of X needs to be (nfeatures, nsamples). The method returns tuple (predictions, decisionvalues).

LIBSVM.svmtrainMethod
svmtrain{T, U<:Real}(X::AbstractMatrix{U}, y::AbstractVector{T}=[];
    svmtype::Type=SVC, kernel::Kernel.KERNEL=Kernel.RadialBasis, degree::Integer=3,
    gamma::Float64=1.0/size(X, 1), coef0::Float64=0.0,
    cost::Float64=1.0, nu::Float64=0.5, epsilon::Float64=0.1,
    tolerance::Float64=0.001, shrinking::Bool=true,
    probability::Bool=false, weights::Union{Dict{T, Float64}, Cvoid}=nothing,
    cachesize::Float64=200.0, verbose::Bool=false)

Train Support Vector Machine using LIBSVM using response vector y and training data X. The shape of X needs to be (nfeatures, nsamples). For one-class SVM use only X.

Arguments

  • svmtype::Type=LIBSVM.SVC: Type of SVM to train SVC (for C-SVM), NuSVCOneClassSVM, EpsilonSVR or NuSVR. Defaults to OneClassSVM if y is not used.
  • kernel::Kernels.KERNEL=Kernel.RadialBasis: Model kernel Linear, polynomial, RadialBasis, Sigmoid or Precomputed.
  • degree::Integer=3: Kernel degree. Used for polynomial kernel
  • gamma::Float64=1.0/size(X, 1) : γ for kernels
  • coef0::Float64=0.0: parameter for sigmoid and polynomial kernel
  • cost::Float64=1.0: cost parameter C of C-SVC, epsilon-SVR, and nu-SVR
  • nu::Float64=0.5: parameter nu of nu-SVC, one-class SVM, and nu-SVR
  • epsilon::Float64=0.1: epsilon in loss function of epsilon-SVR
  • tolerance::Float64=0.001: tolerance of termination criterion
  • shrinking::Bool=true: whether to use the shrinking heuristics
  • probability::Bool=false: whether to train a SVC or SVR model for probability estimates
  • weights::Union{Dict{T, Float64}, Cvoid}=nothing: dictionary of class weights
  • cachesize::Float64=100.0: cache memory size in MB
  • verbose::Bool=false: print training output from LIBSVM if true
  • nt::Integer=0: number of OpenMP cores to use, if 0 it is set to OMPNUMTHREADS, if negative it is set to the max number of threads

Consult LIBSVM documentation for advice on the choise of correct parameters and model tuning.