MESSAGE
DATE | 2017-03-24 |
FROM | Ruben Safir
|
SUBJECT | Subject: [Learn] Decision Tree
|
From learn-bounces-at-nylxs.com Fri Mar 24 17:36:11 2017 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 948BA161313; Fri, 24 Mar 2017 17:36:11 -0400 (EDT) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id A4252161311; Fri, 24 Mar 2017 17:36:07 -0400 (EDT) From: Ruben Safir To: "learn-at-nylxs.com" Message-ID: <2fbe6af3-f715-6c66-7749-a6ee299661e9-at-mrbrklyn.com> Date: Fri, 24 Mar 2017 17:36:07 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Subject: [Learn] Decision Tree X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
http://www.csie.ntu.edu.tw/~sylee/courses/clips/design.htm
12.3 Decision Tree node structure
(deftemplate node (slot name) (slot type) (slot question) (slot yes-node) (slot no-node) (slot answer))
initialize
(defrule initialize (not (node (name root))) => (load-facts "animal.dat") (assert (current-node root)))
ask the question
(deffunction ask-yes-or-no (?question) (printout t ?question " (yes or no) ") (bind ?answer (read)) (while (and (neq ?answer yes) (neq ?answer no)) (printout t ?question " (yes or no) ") (bind ?answer (read))) (return ?answer))
(defrule ask-decision-node-question ?node <- (current-node ?name) (node (name ?name) (type decision) (question ?question)) (not (answer ?)) => (assert (answer (ask-yes-or-no ?question))))
response to the answer
(defrule proceed-to-yes-branch ?node <- (current-node ?name) (node (name ?name) (type decision) (yes-node ?yes-branch)) ?answer <- (answer yes) => (retract ?node ?answer) (assert (current-node ?yes-branch)))
(defrule proceed-to-no-branch ?node <- (current-node ?name) (node (name ?name) (type decision) (no-node ?no-branch)) ?answer <- (answer no) => (retract ?node ?answer) (assert (current-node ?no-branch)))
ask-if-answer-node-is-correct
(defrule ask-if-answer-node-is-correct ?node <- (current-node ?name) (node (name ?name) (type answer) (answer ?value)) (not (answer ?)) => (printout t "I guess it is a " ?value crlf) (assert (answer (ask-yes-or-no "Am I correct?"))))
answer-node-guess
(defrule answer-node-guess-is-correct ?node <- (current-node ?name) (node (name ?name) (type answer)) ?answer <- (answer yes) => (retract ?node ?answer))
(defrule answer-node-guess-is-incorrect ?node <- (current-node ?name) (node (name ?name) (type answer)) ?answer <- (answer no) => (assert (replace-answer-node ?name)) (retract ?node ?answer))
replace-answer-node
(defrule replace-answer-node ?phase <- (replace-answer-node ?name) ?data <- (node (name ?name) (type answer) (answer ?value)) => (retract ?phase) ; Determine what the guess should have been
(printout t "What is the animal? ") (bind ?new-animal (read)) ; Get the question for the guess (printout t "What question when answered yes ") (printout t "will distinguish " crlf " a ") (printout t ?new-animal " from a " ?value "? ") (bind ?question (readline)) (printout t "Now I can guess " ?new-animal crlf) ; Create the new learned nodes
(bind ?newnode1 (gensym*)) (bind ?newnode2 (gensym*)) (modify ?data (type decision) (question ?question) (yes-node ?newnode1) (no-node ?newnode2)) (assert (node (name ?newnode1) (type answer) (answer ?new-animal))) (assert (node (name ?newnode2) (type answer) (answer ?value))) )
-- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|