有人有在 Julia (1.4.1) 中训练支持向量机 (SVM) 的经验吗?
我尝试了 LIBSVM 接口,但是 gituhub 页面上的示例给出了错误:
# Load Fisher's classic iris data
iris = dataset("datasets", "iris")
# LIBSVM handles multi-class data automatically using a one-against-one strategy
labels = convert(Vector, iris[:Species])
# First dimension of input data is features; second is instances
instances = convert(Array, iris[:, 1:4])'
# Train SVM on half of the data using default parameters. See documentation
# of svmtrain for options
model = svmtrain(instances[:, 1:2:end], labels[1:2:end]);```
ERROR: MethodError: no method matching LIBSVM.SupportVectors(::Int32, …Run Code Online (Sandbox Code Playgroud) 我在 Julia 1.4 中工作。我想打开两个大的 gzipped 文件(file1.gz 和 file2.gz),然后从文件 1 中读取第一行,从文件 2 中读取第一行,对这些文件进行处理,然后移至每个文件的第二行文件等。如果我嵌套两个for循环,这显然不起作用,因为它在移动到 file1 的下一行之前循环通过 file2。文件有两大块,可以一次性打开。
handle1 = GZip.open(file1.gz)
handle2 = GZip.open(file2.gz)
for line1 in eachline(handle1)
for line2 in eachline(handle2)
println(line1,line2)
end
end
Run Code Online (Sandbox Code Playgroud)
有简单的解决方案吗?