lisp-matrix direct name conversions.
[CommonLispStat.git] / TODO.lisp
bloba496d13f6e78ecce3a978c8d8cdfdda65f94bcc8
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-01-03 19:36:11 tony>
4 ;;; Creation: <2008-09-08 08:06:30 tony>
5 ;;; File: TODO.lisp
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....
17 ;;; SET UP
19 (in-package :cl-user)
20 ;;(asdf:oos 'asdf:compile-op 'lispstat)
21 ;;(asdf:oos 'asdf:load-op 'lispstat)
24 (in-package :lisp-stat-unittests)
26 (describe (run-tests :suite 'lisp-stat-ut))
27 (run-tests :suite 'lisp-stat-ut)
29 ;; tests = 54, failures = 7, errors = 3
31 (in-package :ls-user)
33 ;;; FIXME: Example: currently not relevant, yet
35 (describe
36 (lift::run-test
37 :test-case 'lisp-stat-unittests::create-proto
38 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
41 :;; FIXME: data frames and structural inheritance
43 ;; Serious flaw -- need to consider that we are not really well
44 ;; working with the data structures, in that Luke created compound as
45 ;; a base class, which turns out to be slightly backward if we are to
46 ;; maintain the numerical structures as well as computational
47 ;; efficiency.
50 #+nil
51 (progn ;; FIXME: Regression modeling
53 (defparameter m nil
54 "holding variable.")
55 ;; need to make vectors and matrices from the lists...
57 (def m (regression-model (list->vector-like iron)
58 (list->vector-like absorbtion) :print nil)) ;;Good
59 (def m (regression-model (list->vector-like iron)
60 (list->vector-like absorbtion)))
62 (def m (regression-model (listoflists->matrix-like (list iron aluminum))
63 (list->vector-like absorbtion) :print nil))
65 (defparameter *indep-vars-1-matrix*
66 (make-matrix 1 (length iron)
67 :initial-contents
68 (list (mapcar #'(lambda (x) (coerce x 'double-float))
69 iron))))
70 ;; *indep-vars-1-matrix*
72 (defparameter *indep-vars-2-matrix*
73 (make-matrix 2 (length iron)
74 :initial-contents
75 (list
76 (mapcar #'(lambda (x) (coerce x 'double-float))
77 iron)
78 (mapcar #'(lambda (x) (coerce x 'double-float))
79 aluminum))))
80 ;; *indep-vars-2-matrix*
83 ;; FAILS due to coercion issues; it just isn't lispy, it's R'y.
84 ;; (defparameter *dep-var* (make-vector (length absorbtion)
85 ;; :initial-contents (list absorbtion)))
86 ;; BUT this should be the right type.
87 (defparameter *dep-var*
88 (make-vector (length absorbtion)
89 :type :row
90 :initial-contents
91 (list
92 (mapcar #'(lambda (x) (coerce x 'double-float))
93 absorbtion))))
94 ;; *dep-var*
97 (defparameter *dep-var-int*
98 (make-vector (length absorbtion)
99 :type :row
100 :element-type 'integer
101 :initial-contents (list absorbtion)))
103 (typep *dep-var* 'matrix-like) ; => T
104 (typep *dep-var* 'vector-like) ; => T
106 (typep *indep-vars-1-matrix* 'matrix-like) ; => T
107 (typep *indep-vars-1-matrix* 'vector-like) ; => T
108 (typep *indep-vars-2-matrix* 'matrix-like) ; => T
109 (typep *indep-vars-2-matrix* 'vector-like) ; => F
111 (def m1 (regression-model-new *indep-vars-1-matrix* *dep-var* ))
112 (def m2 (regression-model-new *indep-vars-2-matrix* *dep-var* ))
114 iron
115 ;; following fails, need to ensure that we work on list elts, not just
116 ;; elts within a list:
117 ;; (coerce iron 'real)
119 ;; the following is a general list-conversion coercion approach -- is
120 ;; there a more efficient way?
121 (mapcar #'(lambda (x) (coerce x 'double-float)) iron)
123 (coerce 1 'real)
125 (send m :compute)
126 (send m :sweep-matrix)
127 (format t "~%~A~%" (send m :sweep-matrix))
129 ;; need to get multiple-linear regression working (simple linear regr
130 ;; works)... to do this, we need to redo the whole numeric structure,
131 ;; I'm keeping these in as example of brokenness...
133 (send m :basis) ;; this should be positive?
134 (send m :coef-estimates) )
136 #+nil
137 (progn ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
138 ;; The following breaks because we should use a package to hold
139 ;; configuration details, and this would be the only package outside
140 ;; of packages.lisp, as it holds the overall defsystem structure.
141 (load-data "iris.lsp") ;; (the above partially fixed).
142 (variables)
143 diabetes )
145 #+nil
146 (progn ;; FIXME: Data.Frames probably deserve to be related to lists --
147 ;; either lists of cases, or lists of variables. We probably do not
148 ;; want to mix them, but want to be able to convert between such
149 ;; structures.
151 (defparameter *my-case-data*
152 '((:cases
153 (:case1 Y Med 3.4 5)
154 (:case2 N Low 3.2 3)
155 (:case3 Y High 3.1 4))
156 (:var-names (list "Response" "Level" "Pressure" "Size"))))
158 *my-case-data*
160 (elt *my-case-data* 1)
161 (elt *my-case-data* 0)
162 (elt *my-case-data* 2) ;; error
163 (elt (elt *my-case-data* 0) 1)
164 (elt (elt *my-case-data* 0) 0)
165 (elt (elt (elt *my-case-data* 0) 1) 0)
166 (elt (elt (elt *my-case-data* 0) 1) 1)
167 (elt (elt (elt *my-case-data* 0) 1) 2)
168 (elt (elt *my-case-data* 0) 3))
170 #+nil
171 (progn ;; FIXME: read data from CSV file. To do.
173 ;; challenge is to ensure that we get mixed arrays when we want them,
174 ;; and single-type (simple) arrays in other cases.
176 (defparameter *csv-num* (read-csv "Data/example-num.csv" :type 'numeric))
177 (defparameter *csv-mix* (read-csv "Data/example-mixed.csv" :type 'data))
179 ;; The handling of these types should be compariable to what we do for
180 ;; matrices, but without the numerical processing. i.e. mref, bind2,
181 ;; make-dataframe, and the class structure should be similar.
183 ;; With numerical data, there should be a straightforward mapping from
184 ;; the data.frame to a matrix. With categorical data (including
185 ;; dense categories such as doc-strings, as well as sparse categories
186 ;; such as binary data), we need to include metadata about ordering,
187 ;; coding, and such. So the structures should probably consider
189 ;; Using the CSV file:
191 (asdf:oos 'asdf:compile-op 'csv :force t)
192 (asdf:oos 'asdf:load-op 'parse-number)
193 (asdf:oos 'asdf:load-op 'csv)
194 (fare-csv:read-csv-file "Data/example-numeric.csv")
196 ;; but I think the cl-csv package is broken, need to use the dsv-style
197 ;; package.