Basic Expert system project program for finals

I need basic format for where the user will be greeted with.

The field is about medical and I have reference guide for where I need to make the AI ask and answer some question related to diseases and symptoms. It's a yes and no C++ program and I'm we are using devc++ Bloodshed as the programming software. I know how to how to code it but I need some advice on how to start because I'm very new to this and all.



Every help is much appreciated, I will be updating you all until the 4th day comes.
Last edited on
Perhaps...

A 2D matrix of booleans, where
- one dimension is the list of diseases, ailments, conditions.
- the other dimension is the list of symptoms, observations.

Your goal is to figure out a suitable question (do you have X symptom / observation) that will bisect the current set of possible list of diseases / ailments / conditions in half.

You might weight the diseases by prevalence, so that common ailments are quickly identified.
I'm using devc++ bloodshed just want to let you know
Which one?

https://www.bloodshed.net/devcpp.html
If it's this one, it was abandoned in 2005 and is woefully obsolete.

https://sourceforge.net/projects/orwelldevcpp/
This one is better.

Bloodshed devc++ 5.11
I'm currently lost atm from asking pattern to assigning each diseases in each void function as well as formulating condition sequences.
closed account (E0p9LyTq)
I'm using devc++ bloodshed just want to let you know

Ouch! If you are using the original Bloodshed Dev C++ that is over 14 years old. Not even C++11 compliant.

If you are using Orwell's fork of Dev C++ it is 4 years old. The compiler it uses is older than that.

You might want to look at Code::Blocks or Visual Studio. Both are free.

If Dev C++ is required by your instructor that is a shame, using outdated tools can make learning Modern C++ harder or impossible.
Last edited on
No doubt our is CLUELESS to newer programming, but then again, I need all the help I can.
cout << "Lupus";

¿what do you need help with? if you have nothing, draw a diagram flow, schematize a user interaction, gives us something to work with.
Last edited on
okay here goes, teach wants us to code a program in which the user will be going through a series of questions asking the user to answer with yes or no. Now, the questions would be related to what a doctor would usually ask a patient, asking the user if she's experiencing cough, headache, muscle ache or something like that with a yes and no answer, and the the output would be to describe what kind of disease she has, perhaps cold or flu. Along with supplementing the user with a treatment of some kind, depending on how the user answered each of the questions the program will output with both the kind of disease and treatment.

here's my progress, I'm sorry if I have a weird English structure.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
#include<iomanip>
#include<string>

using namespace std;

int main()
{

 string userinput;
 string stroke;
 string flu;
 string cold;
 
 
 cout << fixed << "---------------------Expert System: MEDICAL FIELD PROGRAM.----------------------" << endl << endl << endl;
 
 cout << fixed << "---------------------------DISEASES INCLUDED IN PROGRAM-------------------------" << endl;
 cout << fixed << "------------------------------------[Stroke]------------------------------------" << endl;
 cout << fixed << "------------------------------------[FLU]---------------------------------------" << endl;
 cout << fixed << "------------------------------------[COLD]--------------------------------------" << endl << endl;
 
 
 while(userinput != "EXIT || exit"){

 cout << "please enter patient name: " << endl << endl;
 cin  >> userinput;
 
 cout << "Does have the following symptom: Headache " << endl;
 cin  >> userinput;
 
 cout << "Does have the following symptom: Runny nose " << endl;
 cin  >> userinput;
 
 cout << "Does have the following symptom: Sore throat " << endl;
 cin  >> userinput;
  
 cout << "Does have the following symptom: Cough " << endl;
 cin  >> userinput;
 
 cout << "Does have the following symptom: Congestion " << endl;
 cin  >> userinput;
 
 cout << "Does have the following symptom: Body Ache or Mild Headache Sneezing " << endl;
 cin  >> userinput;
 
 cout << "Does have the following symptom: Fever " << endl;
 cin  >> userinput;
 
 }
 

 
 



return 0;

}


I'm having problem connecting the questions to each declared variable, on where to connect what kind of condition will I implement or should I use an array or maybe use void function for each of the declared variables. I'm so lost and I have to finish this until the fourth day, today is the 2nd tomorrow is development presentation and the 4th would be our final presentation including the final programming exercises.
I'm having problem connecting the questions to each declared variable

ok. a really simple way to do this, which may or may not help you.

enum diseases
{
stroke,flu,cold,etc,
max_diseases
};

type diseasevars[max_diseases]; //or a vector, whatever.

diseasevars[flu].hasit = true; //something like this?

you need a couple of these, I think. you need one for the symptoms, one for the diseases, and some way to cross reference them with fuzzy/mathcing logic that picks the best fit disease to the list of given symptoms. It has to work, for example, if they don't list all the symptoms or have an extra symptom or two along with the usual ones, etc. That is someone with a stroke may also have a runny nose, but it should still pick off stroke.

you also want iteration.
you want something that works like this...
for(i = 0; i < max_symptoms; i++)
{
cout << "does patient have " << symptoms[i].textname << endl;
cin>> answer;
symptoms[i].hasit = answer[0] == 'y';
}

note that doing it this way, you can add to the enum and recompile and it just works, if you added new symptoms and diseases. You may need to update the matching for the new inputs but this part of the code would not need updates.
Last edited on
btw i'm using devc++ 5.11 just to let you know

i'll update my work an hour after this. Please keep in touch
All your inputs are going to the same place (userinput). Not a good idea. You should have separate variables for each input.

You need some sort of decision tree. This can be in the form of a series of hard-coded if statements, or more flexibly, a table,

You have to decide if you're going to ask all the questions first, then evaluate your decision tree, or if you're going to use your decision tree to determine what question[s] to ask next (better).
someone could have a stroke AND a cold at the same time, should it handle that scenario?
if not, then I agree, you can tailor what questions to ask by what you already know on top of everything else. But that seems like a nice to have feature..

I don't think this is good for medicine. The stupid thing (no offense to the programmer, but ALL AI systems tend to have moments of AS (artificial stupidity)) would probably figure out they had a cold and ignore the stroke. You would have to be very careful to avoid that sort of output.
Last edited on
it's not complete really complete yet, as I have said I still have many things to fix.
Topic archived. No new replies allowed.