3 ;;; Time-stamp: <2008-12-08 09:39:01 tony>
4 ;;; Creation: <2008-09-08 08:06:30 tony>
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c) 2007-2008, AJ Rossini <blindglobe@gmail.com>. BSD.
8 ;;; Purpose: Stuff that needs to be made working sits inside the progns...
10 ;;; What is this talk of 'release'? Klingons do not make software
11 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
12 ;;; designers and quality assurance people in its wake.
14 ;;; This file contains the current challenges to solve, including a
15 ;;; description of the setup and the work to solve....
20 ;;(asdf:oos 'asdf:compile-op 'lispstat)
21 ;;(asdf:oos 'asdf:load-op 'lispstat)
23 (in-package :lisp-stat-unittests
)
25 (describe (run-tests :suite
'lisp-stat-ut
))
26 (run-tests :suite
'lisp-stat-ut
)
27 ;; tests = 68, failures = 12, errors = 7
31 ;;; FIXME: Example: currently not relevant, yet
35 :test-case
'lisp-stat-unittests
::create-proto
36 :suite
'lisp-stat-unittests
::lisp-stat-ut-proto
))
39 :;; FIXME: data frames and structural inheritance
41 ;; Serious flaw -- need to consider that we are not really well
42 ;; working with the data structures, in that Luke created compound as
43 ;; a base class, which turns out to be slightly backward if we are to
44 ;; maintain the numerical structures as well as computational
51 (progn ;; FIXME: Regression modeling
55 ;; need to make vectors and matrices from the lists...
57 (def m
(regression-model iron absorbtion
:print nil
))
58 (def m
(regression-model (list iron aluminum
) absorbtion
:print nil
))
60 (defparameter *indep-vars-1-matrix
*
61 (make-matrix 1 (length iron
)
63 (list (mapcar #'(lambda (x) (coerce x
'double-float
))
65 ;; *indep-vars-1-matrix*
67 (defparameter *indep-vars-2-matrix
*
68 (make-matrix 2 (length iron
)
71 (mapcar #'(lambda (x) (coerce x
'double-float
))
73 (mapcar #'(lambda (x) (coerce x
'double-float
))
75 ;; *indep-vars-2-matrix*
78 ;; FAILS due to coercion issues; it just isn't lispy, it's R'y.
79 ;; (defparameter *dep-var* (make-vector (length absorbtion)
80 ;; :initial-contents (list absorbtion)))
81 ;; BUT this should be the right type.
82 (defparameter *dep-var
*
83 (make-vector (length absorbtion
)
87 (mapcar #'(lambda (x) (coerce x
'double-float
))
92 (defparameter *dep-var-int
*
93 (make-vector (length absorbtion
)
95 :element-type
'integer
96 :initial-contents
(list absorbtion
)))
98 (typep *dep-var
* 'matrix-like
) ; => T
99 (typep *dep-var
* 'vector-like
) ; => T
101 (typep *indep-vars-1-matrix
* 'matrix-like
) ; => T
102 (typep *indep-vars-1-matrix
* 'vector-like
) ; => T
103 (typep *indep-vars-2-matrix
* 'matrix-like
) ; => T
104 (typep *indep-vars-2-matrix
* 'vector-like
) ; => F
106 (def m1
(regression-model-new *indep-vars-1-matrix
* *dep-var
* ))
107 (def m2
(regression-model-new *indep-vars-2-matrix
* *dep-var
* ))
110 ;; following fails, need to ensure that we work on list elts, not just
111 ;; elts within a list:
112 ;; (coerce iron 'real)
114 ;; the following is a general list-conversion coercion approach -- is
115 ;; there a more efficient way?
116 (mapcar #'(lambda (x) (coerce x
'double-float
)) iron
)
121 (send m
:sweep-matrix
)
122 (format t
"~%~A~%" (send m
:sweep-matrix
))
124 ;; need to get multiple-linear regression working (simple linear regr
125 ;; works)... to do this, we need to redo the whole numeric structure,
126 ;; I'm keeping these in as example of brokenness...
128 (send m
:basis
) ;; this should be positive?
129 (send m
:coef-estimates
) )
132 (progn ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
133 ;; The following breaks because we should use a package to hold
134 ;; configuration details, and this would be the only package outside
135 ;; of packages.lisp, as it holds the overall defsystem structure.
136 (load-data "iris.lsp") ;; (the above partially fixed).
141 (progn ;; FIXME: Data.Frames probably deserve to be related to lists --
142 ;; either lists of cases, or lists of variables. We probably do not
143 ;; want to mix them, but want to be able to convert between such
146 (defparameter *my-case-data
*
150 (:case3 Y High
3.1 4))
151 (:var-names
(list "Response" "Level" "Pressure" "Size"))))
155 (elt *my-case-data
* 1)
156 (elt *my-case-data
* 0)
157 (elt *my-case-data
* 2) ;; error
158 (elt (elt *my-case-data
* 0) 1)
159 (elt (elt *my-case-data
* 0) 0)
160 (elt (elt (elt *my-case-data
* 0) 1) 0)
161 (elt (elt (elt *my-case-data
* 0) 1) 1)
162 (elt (elt (elt *my-case-data
* 0) 1) 2)
163 (elt (elt *my-case-data
* 0) 3))
166 (progn ;; FIXME: read data from CSV file. To do.
168 ;; challenge is to ensure that we get mixed arrays when we want them,
169 ;; and single-type (simple) arrays in other cases.
171 (defparameter *csv-num
* (read-csv "Data/example-num.csv" :type
'numeric
))
172 (defparameter *csv-mix
* (read-csv "Data/example-mixed.csv" :type
'data
))
174 ;; The handling of these types should be compariable to what we do for
175 ;; matrices, but without the numerical processing. i.e. mref, bind2,
176 ;; make-dataframe, and the class structure should be similar.
178 ;; With numerical data, there should be a straightforward mapping from
179 ;; the data.frame to a matrix. With categorical data (including
180 ;; dense categories such as doc-strings, as well as sparse categories
181 ;; such as binary data), we need to include metadata about ordering,
182 ;; coding, and such. So the structures should probably consider
184 ;; Using the CSV file:
186 (asdf:oos
'asdf
:compile-op
'csv
:force t
)
187 (asdf:oos
'asdf
:load-op
'parse-number
)
188 (asdf:oos
'asdf
:load-op
'csv
)
189 (fare-csv:read-csv-file
"Data/example-numeric.csv")
191 ;; but I think the cl-csv package is broken, need to use the dsv-style