[![Actions Status](https://github.com/titsuki/raku-Algorithm-LibSVM/workflows/test/badge.svg)](https://github.com/titsuki/raku-Algorithm-LibSVM/actions) NAME ==== Algorithm::LibSVM - A Raku bindings for libsvm SYNOPSIS ======== EXAMPLE 1 --------- use Algorithm::LibSVM; use Algorithm::LibSVM::Parameter; use Algorithm::LibSVM::Problem; use Algorithm::LibSVM::Model; my \$libsvm = Algorithm::LibSVM.new; my Algorithm::LibSVM::Parameter \$parameter .= new(svm-type => C_SVC, kernel-type => RBF); my Algorithm::LibSVM::Problem \$problem = \$libsvm.load-problem('heart_scale'); my @r = \$libsvm.cross-validation(\$problem, \$parameter, 10); \$libsvm.evaluate(\$problem.y, @r).say; # {acc => 81.1111111111111, mse => 0.755555555555556, scc => 1.01157627463546} EXAMPLE 2 --------- use Algorithm::LibSVM; use Algorithm::LibSVM::Parameter; use Algorithm::LibSVM::Problem; use Algorithm::LibSVM::Model; sub gen-train { my \$max-x = 1; my \$min-x = -1; my \$max-y = 1; my \$min-y = -1; do for ^300 { my \$x = \$min-x + rand * (\$max-x - \$min-x); my \$y = \$min-y + rand * (\$max-y - \$min-y); my \$label = do given \$x, \$y { when (\$x - 0.5) ** 2 + (\$y - 0.5) ** 2 <= 0.2 { 1 } when (\$x - -0.5) ** 2 + (\$y - -0.5) ** 2 <= 0.2 { 2 } default { Nil } } (\$label,"1:\$x","2:\$y") if \$label.defined; }.sort({ \$^a.[0] cmp \$^b.[0] })>>.join(" ") } my Str @train = gen-train; my Pair @test = parse-libsvmformat(q:to/END/).head.flat; 1 1:0.5 2:0.5 END my \$libsvm = Algorithm::LibSVM.new; my Algorithm::LibSVM::Parameter \$parameter .= new(svm-type => C_SVC, kernel-type => LINEAR); my Algorithm::LibSVM::Problem \$problem = \$libsvm.load-problem(@train); my \$model = \$libsvm.train(\$problem, \$parameter); say \$model.predict(features => @test)