From 0575728c5e8bbfee5444f4e86d25392ca5d70f77 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Tue, 21 Apr 2009 08:15:47 +0200 Subject: [PATCH] more code, some working, into linear regression example. Signed-off-by: AJ Rossini --- examples/linear-regression.lisp | 51 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/examples/linear-regression.lisp b/examples/linear-regression.lisp index b4bc225..27cd16e 100644 --- a/examples/linear-regression.lisp +++ b/examples/linear-regression.lisp @@ -1,25 +1,64 @@ ;;; -*- mode: lisp -*- -;;; Time-stamp: <2009-04-19 09:53:09 tony> +;;; Time-stamp: <2009-04-20 18:44:42 tony> ;;; Creation: <2009-04-19 09:41:09 tony> ;;; File: linear-regression.lisp ;;; Author: AJ Rossini ;;; Copyright: (c)2009--, AJ Rossini. BSD, MIT, LLGPL, or ;;; GPLv2+, or GPLv3+ depending on how it arrives. -;;; Purpose: Example of basic exploratory data analysis in CLS. +;;; Purpose: Example of basic linear regression data analysis in 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. - (in-package :ls-user) +;; TODO: +;; - confirm estimates for multivariate case, +;; - pretty-print output +;; - fix up API -- what do we want this to look like? + +(defparameter *m* + (regression-model (list->vector-like iron) + (list->vector-like absorbtion)) + "holding variable.") + +(defparameter *m-fit* + (fit-model *m*)) + +(princ *m*) +(princ *m-fit*) + +(estimates *m-fit*) +(covariance-matrix *m-fit*) + +(defparameter *m3* + (regression-model (transpose + (listoflist->matrix-like + (list iron aluminum) + :orientation :row-major)) + (list->vector-like absorbtion))) +(princ *m3*) +(defparameter *m3-fit* + (fit-model *m3*)) + +#| + ;; Should the above look something like: + (defparameter *m3-fit* + (spec-and-fit-model '(absorbtion = iron aluminum))) + ;; in which case we split the list before/after the "=" character. +|# + +(estimates *m3-fit*) +(covariance-matrix *m3-fit*)) + + + +;; now to build a linear regression model from an external CSV datafile... + (defparameter *my-df* (make-dataframe (rsm.string::filestream->string-table "/path/to/file.dsv")) "Initial read-in of data.") - - -;; now to build a linear regression model from *my-df* -- 2.11.4.GIT