(defun index (x min max b) (let ((pinch 0.000001) (ret)) (setf ret (- (ceiling (/ (- (+ x pinch) min) (+ (/ (- max min) b) pinch))) 1)) ret)) (defun undisc (bins &optional (tbl (thetable))) (let ((cell) (i 0)) (dolist (col (thecols tbl)) (if (typep col 'num) (dolist (row (therows tbl)) (setf cell (nth i (row-cells row))) (setf (nth i (row-cells row)) (index cell (num-min col) (num-max col) bins)))) (incf i)))) (defun undisc2 (bins &optional (tbl (thetable))) (let ((tmpcell) (cell) (i 0) (indextmp) (colname) (key) (mins (make-hash-table :test 'equal)) (maxs (make-hash-table :test 'equal))) (dolist (col (thecols tbl)) (if (typep col 'num) (dolist (row (therows tbl)) (setf tmpcell (nth i (row-cells row))) ;(setf cell (log (+ tmpcell 0.000001))) (setf indextmp (index tmpcell (num-min col) (num-max col) bins)) (setf colname (col-name col)) (setf key `(,colname ,indextmp)) (if (eql indextmp -1) (setf indextmp 0)) (if (< tmpcell (gethash key mins most-positive-fixnum)) (setf (gethash key mins) tmpcell)) (if (> tmpcell (gethash key maxs most-negative-fixnum)) (setf (gethash key maxs) tmpcell)) (setf (nth i (row-cells row)) indextmp) )) (incf i)) ;(print (showh mins)) ;(print (showh maxs)) ;(format t "Col Val Min Max ~%") ;(dolist (col (thecols tbl)) ;(dotimes (j bins) ;(setf key `(,(col-name col) ,j)) ;(format t "~9a ~3a ~5a ~5a ~%" (col-name col) j (gethash key mins nil) (gethash key maxs nil)))) (list mins maxs))) (defun logger (base &optional (tbl (thetable))) (let (i) (dolist (row (table-rows tbl)) (setf i 0) (dolist (cell (row-cells row)) (if (< i 21) (setf (nth i (row-cells row)) (log (+ cell 0.000001) base))) (incf i) )))) (deftest !disc () (data "../data/numeric-lisp/weatherN.lisp") (train) (print (therows)) (undisc 3) (therows))