From: ELB
Subject: Re: Prolog examples please?? HELP?
Date: 
Message-ID: <a0pnrs$pum$1@paris.btinternet.com>
The problem I have is as follows:

To create an expert shell to read in the following



The predicate 'disease' has 4 arguments: a reference number for the disease,
followed by its name, its prior probability in the absence of any other
 information and a symptom list.

   The symptom list comprises a series of numbers in groups of three, one
group
   for each symptom associated with the disease, in the following order:

   (a) The reference number of the symptom
   (b) The probability of the symptom being present in patients who have
         the disease
   (c) The probability of the symptom being present in patients who do not
         have the disease

e.g)

disease(1,'Common
cold',0.02,[1,0.9,0.05,2,0.8,0.02,3,0.8,0.02,5,0.6,0.01,6,0.99,0.01,7,0.2,0.
01,8,0.5,0.01,15,0.8,0.01,34,0.01,0.01]).

The 'symptom' predicate has two arguments: a reference number for the
symptom,
   followed by a question that can be used to ask the user whether or not
the
   symptom is present

e.g)

symptom(1,'Are you sneezing a lot?').


I have used the following coding below before to calculate the probability
using bayes theroem, but I am stuck as to how to modify the following code
to calculate the probability to a symptom relating to a disease and how once
such calculations have been performed how to select an apporriate disease
and display it to the user.  All I'm looking for is the basics to get my
past this stage as I've been stuck for about a week and am a maths student
not a programmer (I need all the help I can get)

find_prob(Disease,Prob):-
   start_prob(Disease,Prior),calcprob(Disease,Prior,Prob),!.

calcprob(Disease,Prior,Post):-
findall([PEH,PEnotH],symptom(Disease,_,PEH,PEnotH),Problist),
calcprob2(Prior,Problist,Post).

calcprob2(Prior,[],Prior):-!.

calcprob2(Prior,[[PEH,PEnotH]|Rest],Post):-
Newval is (PEH*Prior)/((PEH*Prior)+(PEnotH)*(1-Prior)),
calcprob2(Newval,Rest,Post),!.

start_prob(brain_tumour,0.00002).
symptom(brain_tumour,headache,0.7,0.1).
symptom(brain_tumour,unsteadiness,0.1,0.01).
symptom(brain_tumour,depression,0.4,0.25).

Please can you offer any help

ELB
"Martin Sondergaard" <······@nowhere.com> wrote in message
·······················@eurus.uk.clara.net...
> Your question is a bit too difficult to answer,
> I think it needs a long answer.
> We can't really post the source code for an
> expert system shell, it would take too long to type.
>
> Would you like to ask a question that has a short answer?
>
>
> --
> Martin Sondergaard,
> London.
>
>
>

From: jan grant
Subject: Re: Prolog examples please?? HELP?
Date: 
Message-ID: <3C33185D.2EC9E57C@bristol.ac.uk>
ELB wrote:

> disease(1,'Common
> cold',0.02,[1,0.9,0.05,2,0.8,0.02,3,0.8,0.02,5,0.6,0.01,6,0.99,0.01,7,0.2,0.
> 01,8,0.5,0.01,15,0.8,0.01,34,0.01,0.01]).

> Please can you offer any help

One piece of advice (which is purely stylistic but may help you a great
deal in simplifying your list processing stuff) is to wrap your triples
in the
symptom list inside a functor.

Ie:
disease(1, 'Common cold', 0.02, [symptom(1, 0.9, 0.05), symptom(2, 0.8,
0.02), ...]).

Makes processing the list using simple list/set predicates much easier.

jan

PS. Once wrote a symbolic math package for elementary group theory in
FORTRAN 77
so you've my sympathy re maths undergrads and inappropriate
implementation
language choices :-)

-- 
perl -e 's?ck?t??print:perl==pants if $_="Just Another Perl Hacker\n"'
From: ELB
Subject: Re: Prolog examples please?? HELP?
Date: 
Message-ID: <a0vihh$4cn$1@knossos.btinternet.com>
Cheers for the advice, but I have to keep the format the same (lecturers
orders).  Any tips on how to deal with it in the current format?

ELB

"jan grant" <·········@bristol.ac.uk> wrote in message
······················@bristol.ac.uk...
> ELB wrote:
>
> > disease(1,'Common
> >
cold',0.02,[1,0.9,0.05,2,0.8,0.02,3,0.8,0.02,5,0.6,0.01,6,0.99,0.01,7,0.2,0.
> > 01,8,0.5,0.01,15,0.8,0.01,34,0.01,0.01]).
>
> > Please can you offer any help
>
> One piece of advice (which is purely stylistic but may help you a great
> deal in simplifying your list processing stuff) is to wrap your triples
> in the
> symptom list inside a functor.
>
> Ie:
> disease(1, 'Common cold', 0.02, [symptom(1, 0.9, 0.05), symptom(2, 0.8,
> 0.02), ...]).
>
> Makes processing the list using simple list/set predicates much easier.
>
> jan
>
> PS. Once wrote a symbolic math package for elementary group theory in
> FORTRAN 77
> so you've my sympathy re maths undergrads and inappropriate
> implementation
> language choices :-)
>
> --
> perl -e 's?ck?t??print:perl==pants if $_="Just Another Perl Hacker\n"'