From a70a7a30fc62ca0b187ed87d683d94cd2ad75ab1 Mon Sep 17 00:00:00 2001
From: AJ Rossini
Date: Thu, 4 Dec 2008 08:08:44 +0100
Subject: [PATCH] wrapped things "todo" in (progn). Probably should #+nil to
allow for compilation.

TODO.lisp  323 ++++++++++++++++++++++++++++++++++++++
1 file changed, 197 insertions(+), 126 deletions()
rewrite TODO.lisp (65%)
diff git a/TODO.lisp b/TODO.lisp
dissimilarity index 65%
index cb07338..e603ef0 100644
 a/TODO.lisp
+++ b/TODO.lisp
@@ 1,126 +1,197 @@
;;; * mode: lisp *

;;; Timestamp: <20081125 18:56:39 tony>
;;; Creation: <20080908 08:06:30 tony>
;;; File: TODO.lisp
;;; Author: AJ Rossini
;;; Copyright: (c) 20072008, AJ Rossini . BSD.
;;; Purpose: demonstrations of how one might use CLS.

;;; What is this talk of 'release'? Klingons do not make software
;;; 'releases'. Our software 'escapes', leaving a bloody trail of
;;; designers and quality assurance people in its wake.

;;; This file contains the current challenges to solve, including a
;;; description of the setup and the work to solve....

;;; SET UP

(inpackage :cluser)
;;(asdf:oos 'asdf:compileop 'lispstat)
;;(asdf:oos 'asdf:loadop 'lispstat)

(inpackage :lispstatunittests)

(describe (runtests :suite 'lispstatut))
(runtests :suite 'lispstatut)
;; tests = 68, failures = 12, errors = 5

(inpackage :lsuser)

;;; FIXME: Example: currently not relevant, yet
#
 (describe
 (lift::runtest
 :testcase 'lispstatunittests::createproto
 :suite 'lispstatunittests::lispstatutproto))
#

:;; FIXME: data frames and structural inheritance
;;
;; Serious flaw  need to consider that we are not really well
;; working with the data structures, in that Luke created compound as
;; a base class, which turns out to be slightly backward if we are to
;; maintain the numerical structures as well as computational
;; efficiency.



;;; FIXME: Regression modeling

(defparameter m nil
 "holding variable.")
(def m (regressionmodel (list iron aluminum) absorbtion :print nil))
(send m :compute)
(send m :sweepmatrix)
(format t "~%~A~%" (send m :sweepmatrix))

;; need to get multiplelinear regression working (simple linear regr
;; works)... to do this, we need to redo the whole numeric structure,
;; I'm keeping these in as example of brokenness...

(send m :basis) ;; this should be positive?
(send m :coefestimates)

;;; FIXME: Need to clean up data examples, licenses, attributions, etc.

;; The following breaks because we should use a package to hold
;; configuration details, and this would be the only package outside
;; of packages.lisp, as it holds the overall defsystem structure.
(loaddata "iris.lsp") ;; (the above partially fixed).
(variables)
diabetes


;;; FIXME: Data.Frames probably deserve to be related to lists 
;;; either lists of cases, or lists of variables. We probably do not
;;; want to mix them, but want to be able to convert between such
;;; structures.

(defparameter *mycasedata*
 '((:cases
 (:case1 Y Med 3.4 5)
 (:case2 N Low 3.2 3)
 (:case3 Y High 3.1 4))
 (:varnames (list "Response" "Level" "Pressure" "Size"))))

*mycasedata*

(elt *mycasedata* 1)
(elt *mycasedata* 0)
(elt *mycasedata* 2) ;; error
(elt (elt *mycasedata* 0) 1)
(elt (elt *mycasedata* 0) 0)
(elt (elt (elt *mycasedata* 0) 1) 0)
(elt (elt (elt *mycasedata* 0) 1) 1)
(elt (elt (elt *mycasedata* 0) 1) 2)
(elt (elt *mycasedata* 0) 3)


;;; FIXME: read data from CSV file. To do.

;; challenge is to ensure that we get mixed arrays when we want them,
;; and singletype (simple) arrays in other cases.

(defparameter *csvnum* (readcsv "Data/examplenum.csv" :type 'numeric))
(defparameter *csvmix* (readcsv "Data/examplemixed.csv" :type 'data))

;; The handling of these types should be compariable to what we do for
;; matrices, but without the numerical processing. i.e. mref, bind2,
;; makedataframe, and the class structure should be similar.

;; With numerical data, there should be a straightforward mapping from
;; the data.frame to a matrix. With categorical data (including
;; dense categories such as docstrings, as well as sparse categories
;; such as binary data), we need to include metadata about ordering,
;; coding, and such. So the structures should probably consider

;; Using the CSV file:

(asdf:oos 'asdf:compileop 'csv :force t)
(asdf:oos 'asdf:loadop 'parsenumber)
(asdf:oos 'asdf:loadop 'csv)
(farecsv:readcsvfile "Data/examplenumeric.csv")

;; but I think the clcsv package is broken, need to use the dsvstyle
;; package.
+;;; * mode: lisp *
+
+;;; Timestamp: <20081203 07:42:18 tony>
+;;; Creation: <20080908 08:06:30 tony>
+;;; File: TODO.lisp
+;;; Author: AJ Rossini
+;;; Copyright: (c) 20072008, AJ Rossini . BSD.
+;;; Purpose: demonstrations of how one might use CLS.
+
+;;; What is this talk of 'release'? Klingons do not make software
+;;; 'releases'. Our software 'escapes', leaving a bloody trail of
+;;; designers and quality assurance people in its wake.
+
+;;; This file contains the current challenges to solve, including a
+;;; description of the setup and the work to solve....
+
+;;; SET UP
+
+(inpackage :cluser)
+;;(asdf:oos 'asdf:compileop 'lispstat)
+;;(asdf:oos 'asdf:loadop 'lispstat)
+
+(inpackage :lispstatunittests)
+
+(describe (runtests :suite 'lispstatut))
+(runtests :suite 'lispstatut)
+;; tests = 68, failures = 12, errors = 7
+
+(inpackage :lsuser)
+
+;;; FIXME: Example: currently not relevant, yet
+#
+ (describe
+ (lift::runtest
+ :testcase 'lispstatunittests::createproto
+ :suite 'lispstatunittests::lispstatutproto))
+#
+
+:;; FIXME: data frames and structural inheritance
+;;
+;; Serious flaw  need to consider that we are not really well
+;; working with the data structures, in that Luke created compound as
+;; a base class, which turns out to be slightly backward if we are to
+;; maintain the numerical structures as well as computational
+;; efficiency.
+
+
+
+;;; FIXME: Regression modeling
+(progn
+
+ (defparameter m nil
+ "holding variable.")
+ ;; need to make vectors and matrices from the lists...
+ (def m (regressionmodel (list iron aluminum) absorbtion :print nil))
+
+ (defparameter *indepvars1matrix*
+ (makematrix 1 (length iron)
+ :initialcontents
+ (list (mapcar #'(lambda (x) (coerce x 'doublefloat))
+ iron))))
+ ;; *indepvars1matrix*
+
+ (defparameter *indepvars2matrix*
+ (makematrix 2 (length iron)
+ :initialcontents
+ (list
+ (mapcar #'(lambda (x) (coerce x 'doublefloat))
+ iron)
+ (mapcar #'(lambda (x) (coerce x 'doublefloat))
+ aluminum))))
+ ;; *indepvars2matrix*
+
+
+ ;; FAILS due to coercion issues; it just isn't lispy, it's R'y.
+ ;; (defparameter *depvar* (makevector (length absorbtion)
+ ;; :initialcontents (list absorbtion)))
+ ;; BUT this should be the right type.
+ (defparameter *depvar*
+ (makevector (length absorbtion)
+ :type :row
+ :initialcontents
+ (list
+ (mapcar #'(lambda (x) (coerce x 'doublefloat))
+ absorbtion))))
+ ;; *depvar*
+
+
+ (defparameter *depvarint*
+ (makevector (length absorbtion)
+ :type :row
+ :elementtype 'integer
+ :initialcontents (list absorbtion)))
+
+ (typep *depvar* 'matrixlike) ; => T
+ (typep *depvar* 'vectorlike) ; => T
+
+ (typep *indepvars1matrix* 'matrixlike) ; => T
+ (typep *indepvars1matrix* 'vectorlike) ; => T
+ (typep *indepvars2matrix* 'matrixlike) ; => T
+ (typep *indepvars2matrix* 'vectorlike) ; => F
+
+ (def m1 (regressionmodelnew *indepvars1matrix* *depvar* ))
+ (def m2 (regressionmodelnew *indepvars2matrix* *depvar* ))
+
+ iron
+ ;; following fails, need to ensure that we work on list elts, not just
+ ;; elts within a list:
+ ;; (coerce iron 'real)
+
+ ;; the following is a general listconversion coercion approach  is
+ ;; there a more efficient way?
+ (mapcar #'(lambda (x) (coerce x 'doublefloat)) iron)
+
+ (coerce 1 'real)
+
+ (send m :compute)
+ (send m :sweepmatrix)
+ (format t "~%~A~%" (send m :sweepmatrix))
+
+ ;; need to get multiplelinear regression working (simple linear regr
+ ;; works)... to do this, we need to redo the whole numeric structure,
+ ;; I'm keeping these in as example of brokenness...
+
+ (send m :basis) ;; this should be positive?
+ (send m :coefestimates)
+
+
+ )
+
+
+(progn ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
+
+ ;; The following breaks because we should use a package to hold
+ ;; configuration details, and this would be the only package outside
+ ;; of packages.lisp, as it holds the overall defsystem structure.
+ (loaddata "iris.lsp") ;; (the above partially fixed).
+ (variables)
+ diabetes
+ )
+
+(progn
+ ;; FIXME: Data.Frames probably deserve to be related to lists 
+ ;; either lists of cases, or lists of variables. We probably do not
+ ;; want to mix them, but want to be able to convert between such
+ ;; structures.
+
+ (defparameter *mycasedata*
+ '((:cases
+ (:case1 Y Med 3.4 5)
+ (:case2 N Low 3.2 3)
+ (:case3 Y High 3.1 4))
+ (:varnames (list "Response" "Level" "Pressure" "Size"))))
+
+ *mycasedata*
+
+ (elt *mycasedata* 1)
+ (elt *mycasedata* 0)
+ (elt *mycasedata* 2) ;; error
+ (elt (elt *mycasedata* 0) 1)
+ (elt (elt *mycasedata* 0) 0)
+ (elt (elt (elt *mycasedata* 0) 1) 0)
+ (elt (elt (elt *mycasedata* 0) 1) 1)
+ (elt (elt (elt *mycasedata* 0) 1) 2)
+ (elt (elt *mycasedata* 0) 3)
+
+ )
+
+
+(progn ;; FIXME: read data from CSV file. To do.
+
+ ;; challenge is to ensure that we get mixed arrays when we want them,
+ ;; and singletype (simple) arrays in other cases.
+
+ (defparameter *csvnum* (readcsv "Data/examplenum.csv" :type 'numeric))
+ (defparameter *csvmix* (readcsv "Data/examplemixed.csv" :type 'data))
+
+ ;; The handling of these types should be compariable to what we do for
+ ;; matrices, but without the numerical processing. i.e. mref, bind2,
+ ;; makedataframe, and the class structure should be similar.
+
+ ;; With numerical data, there should be a straightforward mapping from
+ ;; the data.frame to a matrix. With categorical data (including
+ ;; dense categories such as docstrings, as well as sparse categories
+ ;; such as binary data), we need to include metadata about ordering,
+ ;; coding, and such. So the structures should probably consider
+
+ ;; Using the CSV file:
+
+ (asdf:oos 'asdf:compileop 'csv :force t)
+ (asdf:oos 'asdf:loadop 'parsenumber)
+ (asdf:oos 'asdf:loadop 'csv)
+ (farecsv:readcsvfile "Data/examplenumeric.csv")
+
+ ;; but I think the clcsv package is broken, need to use the dsvstyle
+ ;; package.
+ )

2.11.4.GIT