notes and paren matching.
[CommonLispStat.git] / src / algorithms / cross-validation.lisp
blobec1e52b5e32c0b2bad432ee021252f47889cba86
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-01-23 13:13:35 tony>
4 ;;; Creation: <2008-03-11 19:18:34 user>
5 ;;; File: cross-validation.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c)2009--, AJ Rossini. BSD, LLGPL, or GPLv2, depending
8 ;;; on how it arrives.
9 ;;; Purpose: cross-validation algorithms for CLS
11 ;;; What is this talk of 'release'? Klingons do not make software
12 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
13 ;;; designers and quality assurance people in its wake.
15 (in-package :cls-algorithms-crossvalidation)
17 ;;; implememented through general macros for a lispy approach. There
18 ;;; could be a functional approach as well, i.e.
19 ;;; (bootstrap data #'function args)
20 ;;;
22 (defmacro with-data-crossvalidate ((list-of-sources-and-var n) @body)
23 "A proposed lispy implementation, such as:
24 (with-data-crossvalidate ((a dataset1)
25 (b dataset2))
26 (some-form-with-inputs a b c))
27 where there could be multiple datasets, with a and b, etc, being
28 bootstrap realizations of dataset1 and dataset2."
29 (Destructure list-of-sources-and-var)
30 (loop repeat n
31 (progn (pull-samples sources)
32 @body)
33 accumulate in result-list))
35 (defmacro with-correlated-data-crossvalidate)
37 (defgeneric crossvalidate (data function args)
38 (:documentation "used such as: (bootstrap dataset t-test :significance 0.5)")
39 (:default-method (funcall #'function (bootstrap-sample data) (values args))))
45 2 possible paradigms:
47 (with-data-crossvalidate ((a dataset1))
48 (t-test a :significance 0.05))
50 (crossvalidate #'t-test a :significance 0.05)