(defun learner-loop (table learner disc bins goal logflg base &optional (looptimes 10) (s 1)) (random-table-sort table) (let ((tbl (copy-table table)) (l (length (table-rows table))) (out '())) (dotimes (i looptimes out) (cond ((= i (- looptimes 1)) (let ((tblst (split-table tbl (* i (floor (/ l looptimes)))))) (funcall learner (first tblst) (second tblst) disc bins goal logflg base))) ((= i 0) (let ((tblst (split-table tbl (floor (/ l looptimes))))) (funcall learner (second tblst) (first tblst) disc bins goal logflg base))) (t (let ((tblst (split-table tbl (floor (* i (/ l looptimes)))))) (let ((tblst2 (split-table (second tblst) (floor (/ l looptimes))))) (funcall learner (combine-table (first tblst) (second tblst2)) (first tblst2) disc bins goal logflg base))))) (setf tbl (copy-table table))))) (defun split-table (tbl n) (let ((tbl1 (make-table :name (table-name tbl) :klasses (table-klasses tbl) :cols (table-cols tbl))) (tbl2 (make-table :name (table-name tbl) :klasses (table-klasses tbl) :cols (table-cols tbl)))) (setf (table-rows tbl1) (get-first-n-rows (table-rows tbl) n)) (setf (table-rows tbl2) (get-first-n-rows (reverse (table-rows tbl)) (- (length (table-rows tbl)) n))) (list tbl1 tbl2))) (defun combine-table (tbl1 tbl2) (let ((tbl (make-table :name (table-name tbl1) :klasses (table-klasses tbl1) :cols (table-cols tbl1)))) (setf (table-rows tbl) (table-rows tbl1)) (dolist (this (table-rows tbl2) tbl) (push this (table-rows tbl))))) (defun random-table-sort (tbl) (dolist (row (table-rows tbl)) (setf (row-sortkey row) (randf 1.0))) (setf (table-rows tbl) (sort (copy-list (table-rows tbl)) #'< :key #'row-sortkey)) tbl) (defun get-first-n-rows (rows n) (let ((out '())) (dotimes (i n out) (push (nth i rows) out))))