;;;; -*- mode:Lisp; syntax:Common-Lisp; package:user -*- ;;;; ;;;; Copyright 1992 Patrick H. Winston. All rights reserved. ;;;; Version 1.1, transferred from master disk on 21 Jan 93 ;;;; ;;;; This file may reference other files containing copyrighted software. ;;;; Any restrictions on the use of such software are described in the ;;;; files containing that software. This file may be freely copied as ;;;; long as this notice is kept intact. ;;;; Purpose: program support for Chapter 19, ;;;; Learning by Recording Cases ;;;; LOAD NEAREST-NEIGHBOR SYSTEM (load "kd.lsp") ;;;; LOAD NEAREST-NEIGHBOR TEST DATA (load "colors.lsp") ;;;; RUN NEAREST-NEIGHBOR TESTS ;;; Create Tree (setf tree (grow-tree samples)) ;;; Display Tree (display-tree tree) ;;; Find Nearest Neighbors ;;Simple, one nearest neighbor: (format t "~%~%Identifying nearest neighbors for u1.") (identify u1 tree) (format t "~%~%Identifying nearest neighbors for u2.") (identify u2 tree) ;;Two nearest neighbors; inverse weighting: (format t "~%~%Identify using two nearest neighbors for u1.") (identify u1 tree 2) ;;Three nearest neighbors; inverse weighting: (format t "~%~%Identify using three nearest neighbors for u1.") (identify u1 tree 3) ;;Three nearest neighbors; just counting colors seen: (format t "~%~%Identify using three nearest neighbors for u1.") (identify u1 tree 3 #'one-no-matter-what) ;;Test corners: (format t "~%~%Identify using nearest neighbor u3.") (identify u3 tree) (format t "~%~%Identify using nearest neighbor u4.") (identify u4 tree) (format t "~%~%Identify using nearest neighbor u5.") (identify u5 tree) (format t "~%~%Identify using nearest neighbor u6.") (identify u6 tree)