Sie sind auf Seite 1von 5

E.T.S.I.

Informtica
Intelligent Systems

Surname, Given name: _________________________________________________


Degree: ______________________________________________________________

Exercise 1 (2.5 points):


The purpose of the Fore and Aft puzzle is to swap the dark and light tokens. The
figure below depicts the initial state. The dark tokens can only be moved down or to the
right. The light tokens can only be moved up or to the left. A token can be moved to an
adjacent empty square or over an opposite colored token. No diagonal moves are
allowed.
You must model this situation as a search problem.

Solution:
A state is a 5x5 matrix with the current arrangement of the blocks, where 8 cells
are unused (the 2x2 blocks at the lower left and upper right corners). A dark token can
be identified by number 1, the empty cell by number 0, and a light token by number 2,
for example.
The state space is the set of all 5x5 matrices where the used cells contain a total
of 8 ones, 8 twos and one zero.
The step cost is always 1. The available actions in a certain state are (provided
that they are possible):
-Move a dark token down, to an adjacent empty square.
-Move a dark token down, over a light token.
-Move a dark token right, to an adjacent empty square.
-Move a dark token right, over a light token.
-Move a light token up, to an adjacent empty square.
-Move a light token up, over a dark token.
-Move a light token left, to an adjacent empty square.
-Move a light token left, over a dark token.
Please note that these actions can be reformulated in terms of moves of the
empty square.
The goal test consists in checking whether the current state has all the light
tokens in the upper left corner and all the dark tokens in the lower right corner.

It is not possible to go back to a previously visited state, so we can use tree


search for this problem. There is only one goal state.
An admissible heuristic is the number of cells which are occupied in the goal
state, and are either empty or occupied by a token of the opposite color in the current
state. Only one token can be moved on one step, and the step cost is one, so this
heuristic is admissible because it is lower or equal than the number of steps needed to
reach the goal state.
The A* algorithm would be suitable for this problem, given the admissible
heuristic we have just presented.
Exercise 2 (2.5 points):
Translate the following argument from natural language to the language of first
order logic:
The enemy of your enemy is your friend.
Everyone has an enemy.
_____________________________________
John has a friend.
Solution:
xyz ( Enemy(x,y) Enemy(y,z) Friend(x,z) )
x y Enemy(y,x)
____________________________________
x Friend(x,John)
where Enemy(x,y) stands for 'x is an enemy of y', and Friend(x,y) stands for 'x is a friend
of y'.
Exercise 3 (2.5 points):
Given the following inference, convert it into conjunctive normal form and use
the resolution algorithm to determine whether it is correct:
PQ
MPQ
|=
MQ
Solution:
The conversion to CNF produces the following clauses:
C1. P Q
C2. M P Q
C3. M
C4. Q

The execution of the propositional resolution algorithm on the above clauses produces
the following clauses:
C5. P Q
C6. Q
C7. False

(2,3)
(1,5)
(4,6)

Since the empty clause is produced, the argument is correct.


Exercise 4 (2.5 points):
Let us consider the Wine data set. The data set consists of the chemical analyses
of 178 samples of Italian wines belonging to three classes named A, B and C. The
number of available samples for each class is: 59, 71, and 48, respectively. Thirteen
chemical features were measured from each sample. All of the features are expressed as
real numbers.
We have to design a system which, given a new unseen sample with its thirteen
features, classifies it into one of the three wine classes.
Solution:
We can use a nearest neighbor model for this classification problem. In general,
given a query point xq in an input space Rn, our task is to estimate yq=h(xq) from a set of
examples {(x1,y1),, (xN,yN)} of size N. In our case:
Each query point is of the form xq=(f1,, f13), i.e. the chemical features of a
previously unseen wine. Note that xq R13.
The range of the function to be estimated h is {A, B, C}, that is, h(xq) { A, B,
C }.
The input space dimension is n=13, since there are thirteen features.
The size of the example set (also called training set) is N=178, since we have
178 wine samples.
The set of examples is formed by tuples (f1,i ;; f13,i ; Classi), where i{1, 2,
, 178} is the index of the sample wine. Please note that Classi{ A, B, C } is the class
that the i-th sample wine belongs to.
In order to compute yq=h(xq) for a previously unseen wine, we take the
plurality vote of the k nearest neighbors, i.e. the output class is the value of h(x) which
appears the most times in NN(k,xq).
We should select the neighborhood size k such that the number of classification
successes is maximized. We must use another set of samples for this purpose, which
does not have any sample in common with the training set. This second set is called the
validation set.

Question 1 (1 point):
Compute the following performance measures from the confusion matrix given
below:
a) Accuracy.
b) True positives, true negatives, false positives, false negatives.

c) Precision, fallout, recall, F-measure.

Predicted class

Actual class
Positive
182
12

Positive
Negative

Negative
31
245

TP + TN
TP
FP
; Recall =
; Fallout =
TP + TN + FP + FN
TP + FN
FP + TN
TP
PrecisionRecall
; F measure = 2
Precision =
TP + FP
Precision + Recall

Accuracy =

Solution:
a)
n11 + n22
=
n11 + n12 + n21 + n 22
182 + 245
0.9085
182 + 31 + 12 + 245

Accuracy =

b)
TP = n11 = 182
TN = n 22 = 245
FP = n12 = 31
FN = n 21 = 12

c)
182
0.8545
182 + 31
31
Fallout =
0.1123
31 + 245
182
Recall =
0.9381
182 + 12
0.8545 0.9381
F measure = 2
= 0.8944
0.8545 + 0.9381

Precision =

Question 2 (1 point):

Design a single layer perceptron which computes the NAND Boolean function:
x1
0
0
1
1

x2
0
1
0
1

F(x1,x2)
1
1
1
0

Solution:

X1

f(x1,x2)

X2

where the activation function f is the step function and w1, w2 = -0,25; = -0,4.

Das könnte Ihnen auch gefallen