Is there someone that has developped a program in order to create a "decisiontree"? Depending The answer to a question leads to another question, and so on, and so on, and there is an option to return to another point in the decisiontree.
Best regards,
Simon.
p.s. I've already got something, but it's not workable. But to get an idea:
Global Data weergeven
do init()
set result=$$ask(0)
write !!,"Result: ",result
}
init() {
kill ^DECISIONTREE
set ^DECISIONTREE(0)="Smoker"
set ^DECISIONTREE(0,"Yes")=1
set ^DECISIONTREE(0,"No")=2
#; Smoker -> Yes
set ^DECISIONTREE(1)="Age"
set ^DECISIONTREE(1,"<30")=3
set ^DECISIONTREE(1,">30")=4
#; Smoker -> No
set ^DECISIONTREE(2)="Diet"
set ^DECISIONTREE(2,"Good")=3
set ^DECISIONTREE(2,"Poor")=4
#; Smoker -> Yes|Age -> <30
set ^DECISIONTREE(3)="Less risk"
#; Smoker -> Yes|Age -> >30
set ^DECISIONTREE(4)="More risk"
#; Smoker -> No|Diet -> Good
set ^DECISIONTREE(5)="Less risk"
#; Smoker -> No|Diet -> Poor
set ^DECISIONTREE(6)="More risk"
}
ask(id) {
set text=(^DECISIONTREE(id))
quit:$data(^DECISIONTREE(id))=1 text
write !,text
set answer=""
for i=1:1 {
set answer=$order(^DECISIONTREE(id,answer),1,nextId)
quit:answer=""
set answer(i)=nextId
write !,$justify(i,3),") ",answer
}
set nextId=$$read(.answer)
quit:nextId="" ""
quit $$ask(nextId)
}
read(&answers) {
write !
do {
write $char(13),"Option? "
read res#1
quit:$zconvert(res,"L")="q"
} while (res="")||('$data(answers(res)))
write !
quit $get(answers(res))
}
USER>d start^tree()
Smoker
1) No
2) Yes
Option? 2
Age
1) <30
2) >30
Option? 1
Result: Less risk
Thanks! I'm running it in IE through Weblink, but I understand what you're doing.
But it need to be somewhat more flexible, because it can hold thousands of questions.
(I need to be able to change positions of the questions/answers for example, all that flexibility)
Best regards,
Simon
It is just a simple working example. But for reali life, it could be in some class. And flexible it will be with good UI, storage anyway for such task is quite simple. How well will be your UI, for organize that tree, so flexible it will be. Here is an example of complete UI, for creatingand running Decision trees. I think you could try to connect this project with Cache. And I think it is possible to find more web-libraries, which could help you.
Hi Simon,
I don´t know wich version of Caché or Ensemble you are running but it is available with DeepSee´s feature for predictive analyses that works with a decision tree PMML file created from a external tool. Let me know if you want additional details.
Regards.