You are on page 1of 11

KENYATTA UNIVERSITY

SCHOOL OF ENGINEERING AND TECHNOLOGY

COMPUTING AND INFORMATION TECHNOLOGY DEPARTMENT

SIT 410: KNOWLEDGE-BASED SYSTEMS

GROUP MEMBERS

1. DENNIS MURIITHI: J31/3432/2018

2. MAXWELL KIAMBATI: J31/5763/2017

3. DAU GAK MALEK: J31EA/13982/2018

4. FRANKLIN MORARA: J31/3437/2018

5. STEPHEN MWANGI NJERI: J31S/17451/2015

6. CHEGE WAWERU: J31S/13316/2018

7. ABUBAKAR OSMAN: J31/4869/2018


QUESTION 1: PROLOG PRODUCTION SYSTEM

Mental disorder expert system

diagnose :-
write('This is an expert system for diagnosis of mental
disorders.'), nl,
write('There are several questions you need to answer for
diagnosis of mental disorders.'), nl, nl,
disorder(X),
write('Condition was diagnosed as '),
write(X),
write('.').
diagnose :-
write('The diagnose was not found.').

%The question predicate will have to determine from the user


%whether or not a given attribute-value pair is true
question(Attribute, Value):-
retract(yes, Attribute, Value), !.
question(Attribute, Value):-
retract(_, Attribute, Value), !, fail.
question(Attribute, Value):-
write('Is the '),
write(Attribute),
write(' - '),
write(Value),
write('?'),
read(Y),
asserta(retract(Y, Attribute, Value)),
Y == yes.

%question with additional argument which contains


%a list of possible values for the attribute.
questionWithPossibilities(Attribute, Value, Possibilities) :-
write('What is the patient`s '), write(Attribute), write('?'),
nl,
write(Possibilities), nl,
read(X),
check_val(X, Attribute, Value, Possibilities),
asserta( retract(yes, Attribute, X) ),
X == Value.

check_val(X, _, _, Possibilities) :- member(X, Possibilities),


!.
check_val(X, Attribute, Value, Possibilities) :-
write(X), write(' is not a legal value, try again.'), nl,
questionWithPossibilities(Attribute, Value, Possibilities).

%retract equips this system with a memory that remembers the


facts that are already
%known because they were already entered by the user at some
point during the interaction.
:- dynamic(retract/3).

%. The program needs to be modified to specify which attributes


are askable
food_amount(X) :- question(food_amount,X).
symptom(X) :- question(symptom,X).
mentality(X) :- question(mentality,X).
cause(X) :- question(cause, X).
indication(X) :- question(indication,X).
social_skill(X) :- question(social_skill,X).
condition(X) :- question(condition, X).
consequence(X) :- question(consquence,X).
specialty(X) :- question(specialty,X).
face_features(X) :- question(face_features,X).
ears_features(X) :- question(ears_features,X).
brain_function(X) :- question(brain_function,X).
perceptions(X) :- question(perceptions, X).
behavior(X) :- questionWithPossibilities(behavior, X,
[repetitive_and_restricted, narcissistic, aggresive]).

disorder(anorexia_nervosa) :- type(eating_disorder),
consequence(low_weight),
food_amount(food_restriction).

disorder(bulimia_nervosa) :- type(eating_disorder),
consequence(purging),
food_amount(binge_eating).

disorder(asperger_syndrome) :-
type(neurodevelopmental_disorder),
specialty(psychiatry),
social_skill(low),
behavior(repetitive_and_restricted).

disorder(dyslexia) :- type(neurodevelopmental_disorder),
social_skill(normal),
perceptions(low),
symptom(trouble_reading).
disorder(autism) :- type(neurodevelopmental_disorder),
social_skill(low),
symptom(impaired_communication).

disorder(tourettes_syndrome) :-
type(neurodevelopmental_disorder),
social_skill(normal),
specialty(neurology),
symptom(motor_tics).

disorder(bipolar_disorder) :- type(psychotic_disorder),
indication(elevated_moods).

disorder(schizophrenia) :- type(psychotic_disorder),
indication(hallucinations).

disorder(down_syndrome) :- type(genetic_disorder),
symptom(delayed_physical_growth),
face_features(long_and_narrow),
ears_features(large),
brain_function(intellectual_disability).

disorder(fragile_X_syndrome) :- type(genetic_disorder),

face_features(small_chin_and_slanted_eyes),
brain_function(intellectual_disability).

type(eating_disorder) :- symptom(abnormal_eating_habits),
mentality(strong_desire_to_be_thin).

type(neurodevelopmental_disorder) :-
condition(affected_nervous_system),
brain_function(abnormal),
cause(genetic_and_enviromental).

type(psychotic_disorder) :- symptom(false_beliefs),
mentality(manic_depressive),
cause(genetic_and_enviromental).

type(genetic_disorder) :- cause(abnormalities_in_genome).
Below are screenshots of the system as executed in SWI-PROLOG IDE.
QUESTION 2:

Neural Networks.

They are a method in AI that teaches computers to process data, based on how the human brain
works. It is a type of machine learning process, referred to as deep learning, and uses
interconnected nodes in a layered structure.  Neural networks include various technologies like
deep learning, and machine learning as a part of Artificial Intelligence (AI)

Neural networks enable the creation of adaptive systems that computers use to learn from their
mistakes and improve continuously.

How neural networks work?

As the word, neural suggests, they are based on the human brain architecture. Artificial neurons
work together to solve a problem. Neural networks (NN) constitute both the input & output
layers, as well as a hidden layer containing units that change input into the output so that the
output layer can utilize the value.
These are the tools for finding patterns that are numerous & complex for programmers to retrieve
and train the machine to recognize the patterns.
The artificial neurons are software modules, called nodes, and the artificial neural networks are
software programs/algorithms that, at their own core, use computing systems to solve
mathematical calculations.

Simple neural networks architecture

A basic neural network has three layers:

● Input layer

Information from the outside world enters the neural network through this layer

● Hidden layer

Take their inputs from the input layer or other hidden layers. They can be more than one layer.
Each analyzes the output from the previous layer, processes it further, and passes it on to the next
layer.

● Output layer.

Displays the final results of all data processing by the artificial neural network.
Types of neural networks

They can be categorized based on how the data flows from the input node to the output node.

1. Feed-forward neural networks.

Process data in one direction. Uses a feedback process to improve predictions over time.

2. Back propagation algorithms


Continuous learning is achieved by corrective feedback loops to improve their predictive
analytics.

How a corrective feedback loop works

● Each node makes a guess about the next node in the pathway
● It checks if the guess is correct. If correct, the path is assigned a higher weight,
otherwise a lower weight
● For the next data point, the nodes make a new prediction using the higher weight
paths and then repeat step 1
3. Convolutional neural networks

The hidden layers in this type perform specific mathematical functions/, filtering, called
convolutions. Heavily used image processing and classification

Uses of neural networks

● Medical diagnosis by medical image classification


● Targeted marketing by social network filtering and behavioral data analysis.
● Financial predictions by processing historical data of financial instruments
● Electrical load and energy demand forecasting
● Process and quality control
● Chemical compound identification.

Strategies of Machine Learning in ANN

Artificial neural networks have the ability to learn but they should be trained. There are many
learning strategies namely:

● Supervised Learning: It involves a scholar. For example, the scholar gives examples
while preaching for a better understanding of the moral. In the same way, ANN
implements pattern recognition where it starts guessing while recognizing. Then, the
trained data patterns provide the ANN with the answers.
● Unsupervised Learning: It comes to action when there is no sample data set with known
answers. Searching for hidden patterns is one such example. The concept of clustering
involves dividing the elements into sets of groups, which is based on unknown patterns
that are carried out using existing data sets.
● Reinforcement Learning: It is a strategy built based on observation. The ANN takes a
decision by considering its environment. If the observations are supposed to be negative,
the network adjusts its data to make a different decision for next time.

Advantages of neural networks

Here are some of the advantages of neural networks are listed below

● Self-organization: NN can generate its own representation of the information that it


receives at the time of learning.
● Real-Time Operation: NN calculations may be done simultaneously, and some special
(hardware) devices are manufactured which take advantage of this capability.
● Adaptive learning: The capability to learn how to solve tasks is based on the data given
for the training set.
● Redundant Information Coding Through Fault Tolerance: Semi-destruction of a
network leads to degradation of corresponding performance. Moreover, some networks
will have the ability to retain data even when major network damage occurs.

The Disadvantages of Neural Network

The main advantage of the neural network lies in its ability to outperform every machine
learning algorithm, but this also goes along with some disadvantages. Here are some of the
disadvantages of the neural network.

1. Black box: One of the most distinguishing disadvantages of the neural network is its
‘’black box” nature. It means that we don’t know how and why the neural network came
up with a certain output. For instance, when you put an apple’s picture into a neural
network and predict it’s a cat, it’s very difficult to comprehend what led this forecast to
come up with. When you have human interpretable characteristics, understanding the
cause of your error is much simpler

2. Amount of data: Neural networks require much more data than any other traditional
machine learning algorithms, as in at least thousands if not millions of labeled samples.
This is a serious problem and many machine learning problems can be solved usinlesser
data in any other algorithms. This leads to the problem of over-fitting and generalization.
The mode relies more on the training data and may be tuned to the data. Although there
are some cases where the neural network has a deal with little data, most of the time they
don’t.
3. Computationally expensive: Neural networks are more computationally expensive than
any other traditional algorithms. Most of the traditional machine learning algorithms take
much less time to train, ranging from a few minutes to a few hours or days. The amount
of computational power that a Neural Network needs depends heavily on the size of your
data, but also the depth and complexity of your network.

4. Determination of proper network structure: There is no specific rule for determining


the structure of a neural network. The appropriate network structure is achieved through
experience and trial and error.

5. The duration of the network is unknown: Reducing the network to a certain value of


the sampling error implies completing the training. This value does not offer us the best
outcomes.

Applications of neural networks

1. Computer vision.

Neural networks enable computers to extract information and insights from images and videos

2. Speech recognition

Neural networks enable the analyzing of speech despite of varying speech patterns, tone, pitch,
language

3. Natural language processing

Computers use neural networks to gather insights and meanings from text data and documents

4. Recommendation engines

Neural networks can track user activity to develop personalized recommendations.

You might also like