High level libsvm binding for Emacs lisp. Learning to use dynamic modules in Emacs >=25. The example below trains a classifier on the iris dataset with 90 (30 each class) samples for training and 60 (20 each class) for testing.
(require 'esvm)
;; Sets the variables x-train, y-train, x-test and y-test
(load-file "./example.el")
(defun accuracy (y-true y-pred)
"Return accuracy of prediction"
(let ((matches (mapcar* #'= y-true y-pred)))
(/ (length (cl-remove-if (lambda (x) (null x)) matches))
(* 0.01 (length matches)))))
(let* ((model (esvm-fit x-train y-train))
(predictions (esvm-predict model x-test)))
(format "Prediction accuracy: %f%%" (accuracy y-test predictions)))
Prediction accuracy: 96.666667%