using LIBSVM
using RDatasets#导入库
iris=dataset("datasets","iris")#导入数据集,此数据集为150*5的DataFrame,前四列为Float64,第五列为String
features=Matrix(iris[!,1:4])#特征
labels=Vector(Array(iris[!,5]))#标志
features_train,features_test=features[1:2:end,:],features[2:2:end,:]
labels_train,labels_test=labels[1:2:end,:],labels[2:2:end,:]#此处划分训练集和测试集
model = svmtrain(features_train,labels_train)#建立模型,也是在这一步报错
在最后一步报错:
MethodError: no method matching svmtrain(::Matrix{Float64}, ::Matrix{String})
Closest candidates are:
svmtrain(::AbstractMatrix{U}) where U<:Real at C:\Users\ASUS\.julia\packages\LIBSVM\IZl0L\src\LIBSVM.jl:307
svmtrain(::AbstractMatrix{U}, ::AbstractVector{T}; svmtype, kernel, degree, gamma, coef0, cost, nu, epsilon, tolerance, shrinking, probability, weights, cachesize, verbose, nt) where {T, U<:Real} at C:\Users\ASUS\.julia\packages\LIBSVM\IZl0L\src\LIBSVM.jl:307