Nouveau Document CT 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

‫اﻟ ـ ـﺠ ـ ــﻤـ ـ ـ ـ ـ ـﻮر ـ ـﺔ اﻟـ ـﺠ ـ ـ ـﺰاﺋ ـ ـﺮ ـ ـﺔ اﻟ ـ ـﺪﻳ ـ ـﻤـ ـﻘ ـ ـ ـﺮاﻃ ـ ـﻴ ـ ـﺔ اﻟـ ـﺸ ـ ـﻌ ـ ـﺒ ـ ـﻴ ـ ـﺔ‬ Full name :

Democratic and popular republic of Algeria


Ziane ACHOUR university of Djelfa ‫وزارة اﻟـ ـ ـ ـﺘ ـ ـ ـ ـﻌـ ـ ـ ـﻠ ـ ـ ـ ـ ـﻴـ ـ ـ ـ ـ ـ ـ ـ ـﻢ اﻟ ـ ـ ـ ـﻌ ـ ـ ـ ـﺎﻟـ ـ ـ ـ ـ ـ ـ ـ ـ ـ ــﻲ و اﻟـ ـ ـ ـﺒ ـ ـ ـ ـﺤـ ـ ـ ـ ـ ـ ـ ـ ـﺚ اﻟـ ـ ـ ـﻌ ـ ـ ـ ـﻠ ـ ـ ـ ـﻤ ـ ـ ـ ـ ـ ـ ـ ـ ـ ـﻲ‬
Faculty of Exact and Computer Sciences Ministry of higher education and scientific
research
Department of Mathematics & Informatics
Data analysis
Level: M1 Informatics (TAIP) EXAM
Duration: 1 H 2021-2022

Exercise 1:
Table1
Customers and sellers of used cars need a prediction system to predict x1 x2 x3 y
and determine the price of used cars effectively. For that gradient descent 10 4 2 1,45
10 3 1,7 1,5
algorithm is the heart of car price prediction systems, because it can
11 4 2,05 1,37
adjust the parameters (theta) of the model on which the prediction
12 4 2,3 1,22
system is based.
12 5 2,5 1,15
Table 1 shows data set for one car model, where, car price changes 14 8 2,95 1,02
x1: car age.
depending on different factors (features).
x2: transmission and number of
owners.
1 . Based on our case, Select true or false for each statement, and
x3: kilometres driven (x105 klm)
justify your choices. y: car price (x106 –Alg Dinar- ).
a . Car price prediction system uses technique from machine learning. (0,25+0,75 pt) False  True
 The system uses a dataset (train from the data).
 Improve automatically the model (adjust model parameters) in order to make decisions and
predictions based on new data.
b. To predict price of new input car, The proposed problem is a classification.  False True
(0,25+0,75 pt)
 A classification problem is when the output variable is a category (discrete value).
 The proposed problem is a regression problem because the output variable (price) is a real value
(continue value).
c . Regression is an unsupervised technique. (0,25+0,75 pt)  False True
 Regression is supervised technique because the data we need to have includes both the input and
output.
d . The independent variables are : x1 , y. (0,25+0,25 pt)  False True
 The independent variables are: x1, x2 and x3.
e . Number of training data (samples) is equal=3 (m=3). (0,25+0,25 pt)  False True
 Number of training data (samples) is equal 6 (m=6).
f . Number of features is equal=6 (n=6). (0,25+0,25 pt)  False True
 Number of features is equal 3 (n=3).
g. The hypothesis equation h(x) is: ℎ( ) = = + + . (0,25+0,75 pt)  False True
 The number of feature n=3 and j=n+1, so number of theta is 4 and they are ( , , ) . The
hypothesis written as follow: ℎ( ) = = + + + .
2. Using Gradient descent algorithm calculate theta (Ѳ) values (two iterations), where α=0.01 and initial
theta values are ones (Ѳ0,1,2,... =1).

1/3
2. Calculating of theta:

Preliminary data:
A. The formula has the form: //0,25 pt)
ℎ( ) = = + + + .

B. Determine the matrix Theta: //0,25 +0,5 pt


⎡ ⎤
⎢ ⎥
=⎢ ⋮ ⎥ == ==≫ = ==≫ =[ ]
⎢⋮⎥
⎣ ⎦
C. Determine the matrix X: //0,25 +0,5 pt
⎡ ⎤ 01 01 01 01 01 01
⎢ ⎥ 10 10 11 12 12 14
= ⎢ ⋮ ⎥ == ==≫ = ==≫ = 04 03 04 04 05 08
⎢⋮⎥ 02 1,7 2,05 2,3 2,5 2,95
⎣ ⎦
First iteration
A. Calculating of h(x): //1.00 pt
01 01 01 01 01 01
10 10 11 12 12 14
ℎ( ) = =[ 0 1 2 3 ] × 04 03 04 04 05 08 =

02 1,7 2,05 2,3 2,5 2,95


01 01 01 01 01 01
10 10 11 12 12 14
ℎ( ) = [1 1 1 1] × 04 03 04 04 05 08 = [17 15,7 18,05 19,30 20,5 25,95]

02 1,7 2,05 2,3 2,5 2,95

B. The calculations related on h(x) are on the table below: //0,5 +1 pt


x0 x1 x2 x3 y The first version
() () ()
ℎ ℎ (ℎ (ℎ ( ) (ℎ ()
(ℎ ()
() () () () ()
− − ( )) − ( )) − ()
) − ()
)
1 10 4 2 1,45 17 15,55 15,55 155,5 62,2 31,1
1 10 3 1,7 1,5 15,7 14,2 14,2 142 42,6 24,14
1 11 4 2,05 1,37 18,05 16,68 16,68 183,48 66,72 34,194
1 12 4 2,3 1,22 19,30 18,08 18,08 216,96 72,32 41,584
1 12 5 2,5 1,15 20,50 19,35 19,35 232,2 96,75 48,375
1 14 8 2,95 1,02 25,95 24,93 24,93 349,02 199,44 73,5435
SUM 108,79 1279,2 540,03 252,9365
C. , , : //6pts=(0,25 +0,5+0,75)x4

() () () 0.01
≔ − ((ℎ − ) )=1− × 108,79 = 0.8187
6

() () () 0.01
≔ − ((ℎ − ) )=1− × 1279,2 = −1.1319
6

() () () 0.01
≔ − ((ℎ − ) )=1− × 540,03 = 0.1
6

() () () 0.01
≔ − ((ℎ − ) )=1− × 252,9365 = 0.5784
6

2/3
Second iteration
A. Calculating of h(x): //0,75 pt

ℎ( ) =
01 01 01 01 01 01
10 10 11 12 12 14
ℎ( ) = [ . − . . . ] × 04 03 04 04 05 08
02 1,7 2,05 2,3 2,5 2,95
= [−8,944 − 9,2175 − 10,047 − 11,0343 − 10,8187 − 12,5224]

B. The calculations related on h(x) are on the table below: //1,00 pt


x0 x1 x2 x3 y The second version
() () ()
ℎ ℎ (ℎ (ℎ ( ) (ℎ ( ) (ℎ ()
() ( ) () () ()
− − ( )) − ( )) − ( )) − ( ))
1 10 4 2 1,45 -8,944 -10,394 -10,394 -103,9397 -41,5759 -20,7879
1 10 3 1,7 1,5 -9,2175 -10,7175 -10,7175 -107,1745 -32,1524 -18,2197
1 11 4 2,05 1,37 -10,047 -11,417 -11,417 -125,5868 -45,6679 -23,4048
1 12 4 2,3 1,22 -11,0343 -12,2543 -12,2543 -147,0517 -49,0172 -28,1849
1 12 5 2,5 1,15 -10,8187 -11,9687 -11,9687 -143,624 -59,8433 -29,9217
1 14 8 2,95 1,02 -12,5224 -13,5424 -13,5424 -189,5934 -108,3391 -39,95
SUM -70,2938 -816,9702 -336,5959 -160.4691

C. , , calculating: //2pts =(0,5x4 )

() () () 0.01
≔ − ((ℎ − ) )= . − × (−70,2938) = 0.9358
6

() () () 0.01
≔ − ((ℎ − ) )= − . − × (−816,9702) = 0.2297
6

() () () 0.01
≔ − ((ℎ − ) )= . − × (−336,5959) = 0.6609
6

() () () 0.01
≔ − ((ℎ − ) )= . − × (−160,4691) = 0.8459
6

After two iterations the formula is written as follows: //0,5 pt)

ℎ( ) = = 0,9358 + 0,2297 + 0,6609 + 0,8459 .

3/3

You might also like