mirror of https://github.com/01-edu/Branch-AI.git
Badr Ghazlane
2 years ago
47 changed files with 340 additions and 297 deletions
@ -1 +1 @@
|
||||
1. This question is validated if the MSE outputted is **2.25**. |
||||
##### The question 1 is validated if the MSE outputted is **2.25**. |
@ -1 +1 @@
|
||||
1. This question is validated if the accuracy outputted is **0.5714285714285714**. |
||||
##### The question 1 is validated if the accuracy outputted is **0.5714285714285714**. |
||||
|
@ -1,28 +1,32 @@
|
||||
1. This question is validated if the predictions on the train set and test set are: |
||||
##### The exercice is validated is all questions of the exercice are validated |
||||
|
||||
```console |
||||
# 10 first values Train |
||||
array([1.54505951, 2.21338527, 2.2636205 , 3.3258957 , 1.51710076, |
||||
1.63209319, 2.9265211 , 0.78080924, 1.21968217, 0.72656239]) |
||||
``` |
||||
##### The question 1 is validated if the predictions on the train set and test set are: |
||||
|
||||
```console |
||||
#10 first values Test |
||||
```console |
||||
#10 first values Train |
||||
array([1.54505951, 2.21338527, 2.2636205 , 3.3258957 , 1.51710076, |
||||
1.63209319, 2.9265211 , 0.78080924, 1.21968217, 0.72656239]) |
||||
|
||||
``` |
||||
|
||||
array([ 1.82212706, 1.98357668, 0.80547979, -0.19259114, 1.76072418, |
||||
3.27855815, 2.12056804, 1.96099917, 2.38239663, 1.21005304]) |
||||
``` |
||||
```console |
||||
#10 first values Test |
||||
|
||||
2. This question is validated if the results match this output: |
||||
array([ 1.82212706, 1.98357668, 0.80547979, -0.19259114, 1.76072418, |
||||
3.27855815, 2.12056804, 1.96099917, 2.38239663, 1.21005304]) |
||||
|
||||
```console |
||||
r2 on the train set: 0.3552292936915783 |
||||
MAE on the train set: 0.5300159371615256 |
||||
MSE on the train set: 0.5210784446797679 |
||||
``` |
||||
|
||||
r2 on the test set: 0.30265471284464673 |
||||
MAE on the test set: 0.5454023699809112 |
||||
MSE on the test set: 0.5537420654727396 |
||||
``` |
||||
##### The question 2 is validated if the results match this output: |
||||
|
||||
```console |
||||
r2 on the train set: 0.3552292936915783 |
||||
MAE on the train set: 0.5300159371615256 |
||||
MSE on the train set: 0.5210784446797679 |
||||
|
||||
r2 on the test set: 0.30265471284464673 |
||||
MAE on the test set: 0.5454023699809112 |
||||
MSE on the test set: 0.5537420654727396 |
||||
``` |
||||
|
||||
This result shows that the model has slightly better results on the train set than the test set. That's frequent since it is easier to get a better grade on an exam we studied than an exam that is different from what was prepared. However, the results are not good: r2 ~ 0.3. Fitting non linear models as the Random Forest on this data may improve the results. That's the goal of the exercise 5. |
@ -1,72 +1,72 @@
|
||||
1. Some of the algorithms use random steps (random sampling used by the `RandomForest`). I used `random_state = 43` for the Random Forest, the Decision Tree and the Gradient Boosting. This question is validated of the scores you got are close to: |
||||
##### The question is validated of the scores you output are close to the scores below. Some of the algorithms use random steps (random sampling used by the `RandomForest`). I used `random_state = 43` for the Random Forest, the Decision Tree and the Gradient Boosting. |
||||
|
||||
```console |
||||
# Linear regression |
||||
```console |
||||
# Linear regression |
||||
|
||||
TRAIN |
||||
r2 on the train set: 0.34823544284172625 |
||||
MAE on the train set: 0.533092001261455 |
||||
MSE on the train set: 0.5273648371379568 |
||||
TRAIN |
||||
r2 on the train set: 0.34823544284172625 |
||||
MAE on the train set: 0.533092001261455 |
||||
MSE on the train set: 0.5273648371379568 |
||||
|
||||
TEST |
||||
r2 on the test set: 0.3551785428138914 |
||||
MAE on the test set: 0.5196420310323713 |
||||
MSE on the test set: 0.49761195027083804 |
||||
TEST |
||||
r2 on the test set: 0.3551785428138914 |
||||
MAE on the test set: 0.5196420310323713 |
||||
MSE on the test set: 0.49761195027083804 |
||||
|
||||
|
||||
# SVM |
||||
# SVM |
||||
|
||||
TRAIN |
||||
r2 on the train set: 0.6462366150965996 |
||||
MAE on the train set: 0.38356451633259875 |
||||
MSE on the train set: 0.33464478671339165 |
||||
TRAIN |
||||
r2 on the train set: 0.6462366150965996 |
||||
MAE on the train set: 0.38356451633259875 |
||||
MSE on the train set: 0.33464478671339165 |
||||
|
||||
TEST |
||||
r2 on the test set: 0.6162644671183826 |
||||
MAE on the test set: 0.3897680598426786 |
||||
MSE on the test set: 0.3477101776543003 |
||||
TEST |
||||
r2 on the test set: 0.6162644671183826 |
||||
MAE on the test set: 0.3897680598426786 |
||||
MSE on the test set: 0.3477101776543003 |
||||
|
||||
|
||||
# Decision Tree |
||||
# Decision Tree |
||||
|
||||
TRAIN |
||||
r2 on the train set: 0.9999999999999488 |
||||
MAE on the train set: 1.3685733933909677e-08 |
||||
MSE on the train set: 6.842866883530944e-14 |
||||
TRAIN |
||||
r2 on the train set: 0.9999999999999488 |
||||
MAE on the train set: 1.3685733933909677e-08 |
||||
MSE on the train set: 6.842866883530944e-14 |
||||
|
||||
TEST |
||||
r2 on the test set: 0.6263651902480918 |
||||
MAE on the test set: 0.4383758696244002 |
||||
MSE on the test set: 0.4727017198871596 |
||||
TEST |
||||
r2 on the test set: 0.6263651902480918 |
||||
MAE on the test set: 0.4383758696244002 |
||||
MSE on the test set: 0.4727017198871596 |
||||
|
||||
|
||||
# Random Forest |
||||
# Random Forest |
||||
|
||||
TRAIN |
||||
r2 on the train set: 0.9705418471542886 |
||||
MAE on the train set: 0.11983836612191189 |
||||
MSE on the train set: 0.034538356420577995 |
||||
TRAIN |
||||
r2 on the train set: 0.9705418471542886 |
||||
MAE on the train set: 0.11983836612191189 |
||||
MSE on the train set: 0.034538356420577995 |
||||
|
||||
TEST |
||||
r2 on the test set: 0.7504673649554309 |
||||
MAE on the test set: 0.31889891600404635 |
||||
MSE on the test set: 0.24096164834441108 |
||||
TEST |
||||
r2 on the test set: 0.7504673649554309 |
||||
MAE on the test set: 0.31889891600404635 |
||||
MSE on the test set: 0.24096164834441108 |
||||
|
||||
|
||||
# Gradient Boosting |
||||
# Gradient Boosting |
||||
|
||||
TRAIN |
||||
r2 on the train set: 0.7395782392433273 |
||||
MAE on the train set: 0.35656543036682264 |
||||
MSE on the train set: 0.26167490389525294 |
||||
TRAIN |
||||
r2 on the train set: 0.7395782392433273 |
||||
MAE on the train set: 0.35656543036682264 |
||||
MSE on the train set: 0.26167490389525294 |
||||
|
||||
TEST |
||||
r2 on the test set: 0.7157456298013534 |
||||
MAE on the test set: 0.36455447680396397 |
||||
MSE on the test set: 0.27058170064218096 |
||||
TEST |
||||
r2 on the test set: 0.7157456298013534 |
||||
MAE on the test set: 0.36455447680396397 |
||||
MSE on the test set: 0.27058170064218096 |
||||
|
||||
``` |
||||
``` |
||||
|
||||
It is important to notice that the Decision Tree over fits very easily. It learns easily the training data but is not able to extrapolate on the test set. This algorithm is not used a lot. |
||||
It is important to notice that the Decision Tree overfits very easily. It learns easily the training data but is not able to extrapolate on the test set. This algorithm is not used a lot its overfitting ability. |
||||
|
||||
However, Random Forest and Gradient Boosting propose a solid approach to correct the over fitting (in that case the parameters `max_depth` is set to None that is why the Random Forest over fits the data). These two algorithms are used intensively in Machine Learning Projects. |
||||
|
@ -1 +1 @@
|
||||
1. This question is validated the output is: **0.9524917424084265** |
||||
##### The question 1 is validated the output is: **0.9524917424084265** |
@ -1,2 +1,2 @@
|
||||
1. This question is validated if the output is: **0.5472899351247816**. |
||||
##### The question 1 is validated if the output is: **0.5472899351247816**. |
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
1. This question is validated if the output is: |
||||
``` |
||||
Bob: 0.7855253278357536 |
||||
Eli: 0.7771516558846259 |
||||
Tom: 0.8067873659804015 |
||||
Ryan: 0.7892343955586032 |
||||
``` |
||||
2. This question is validated if the logloss for the 4 students is **0.5485133607757963**. |
||||
##### The exercice is validated is all questions of the exercice are validated |
||||
|
||||
##### The question 1 is validated if the output is: |
||||
``` |
||||
Bob: 0.7855253278357536 |
||||
Eli: 0.7771516558846259 |
||||
Tom: 0.8067873659804015 |
||||
Ryan: 0.7892343955586032 |
||||
``` |
||||
##### The question 2 is validated if the logloss for the 4 students is **0.5485133607757963**. |
||||
|
@ -1,12 +1,14 @@
|
||||
1. This question is validated if the output is **7**. |
||||
##### The exercice is validated is all questions of the exercice are validated |
||||
|
||||
2. This question is validated if the outputs are: |
||||
##### The question 1 is validated if the output is **7**. |
||||
|
||||
``` |
||||
Bob: 14.918863163724454 |
||||
Eli: 14.83137890625537 |
||||
Tom: 15.086662606964074 |
||||
Ryan: 14.939270885974128 |
||||
``` |
||||
##### The question 2 is validated if the outputs are: |
||||
|
||||
3. This question is validated if the MSE is **10.237608699909138** |
||||
``` |
||||
Bob: 14.918863163724454 |
||||
Eli: 14.83137890625537 |
||||
Tom: 15.086662606964074 |
||||
Ryan: 14.939270885974128 |
||||
``` |
||||
|
||||
##### The question 3 is validated if the MSE is **10.237608699909138** |
@ -1 +1 @@
|
||||
1. This question is validated if the output is: `<tensorflow.python.keras.engine.sequential.Sequential object at xxx` |
||||
##### The question 1 is validated if the output is: `<tensorflow.python.keras.engine.sequential.Sequential object at xxx` |
@ -1,56 +1,58 @@
|
||||
1. This question is validated if the fields`batch_input_shape`,`units` and `activation` match this output: |
||||
##### The exercice is validated is all questions of the exercice are validated |
||||
|
||||
``` |
||||
{'name': 'dense_7', |
||||
'trainable': True, |
||||
'batch_input_shape': (None, 5), |
||||
'dtype': 'float32', |
||||
'units': 8, |
||||
'activation': 'sigmoid', |
||||
'use_bias': True, |
||||
'kernel_initializer': {'class_name': 'GlorotUniform', |
||||
'config': {'seed': None}}, |
||||
'bias_initializer': {'class_name': 'Zeros', 'config': {}}, |
||||
'kernel_regularizer': None, |
||||
'bias_regularizer': None, |
||||
'activity_regularizer': None, |
||||
'kernel_constraint': None, |
||||
'bias_constraint': None} |
||||
``` |
||||
##### The question 1 is validated if the fields `batch_input_shape`, `units` and `activation` match this output: |
||||
|
||||
2. This question is validated if the fields`units` and `activation` match this output: |
||||
``` |
||||
{'name': 'dense_7', |
||||
'trainable': True, |
||||
'batch_input_shape': (None, 5), |
||||
'dtype': 'float32', |
||||
'units': 8, |
||||
'activation': 'sigmoid', |
||||
'use_bias': True, |
||||
'kernel_initializer': {'class_name': 'GlorotUniform', |
||||
'config': {'seed': None}}, |
||||
'bias_initializer': {'class_name': 'Zeros', 'config': {}}, |
||||
'kernel_regularizer': None, |
||||
'bias_regularizer': None, |
||||
'activity_regularizer': None, |
||||
'kernel_constraint': None, |
||||
'bias_constraint': None} |
||||
``` |
||||
|
||||
``` |
||||
{'name': 'dense_8', |
||||
'trainable': True, |
||||
'dtype': 'float32', |
||||
'units': 4, |
||||
'activation': 'sigmoid', |
||||
'use_bias': True, |
||||
'kernel_initializer': {'class_name': 'GlorotUniform', |
||||
'config': {'seed': None}}, |
||||
'bias_initializer': {'class_name': 'Zeros', 'config': {}}, |
||||
'kernel_regularizer': None, |
||||
'bias_regularizer': None, |
||||
'activity_regularizer': None, |
||||
'kernel_constraint': None, |
||||
'bias_constraint': None} |
||||
``` |
||||
3. This question is validated if the fields`units` and `activation` match this output: |
||||
##### The question 2 is validated if the fields `units` and `activation` match this output: |
||||
|
||||
``` |
||||
{'name': 'dense_9', |
||||
'trainable': True, |
||||
'dtype': 'float32', |
||||
'units': 1, |
||||
'activation': 'sigmoid', |
||||
'use_bias': True, |
||||
'kernel_initializer': {'class_name': 'GlorotUniform', |
||||
'config': {'seed': None}}, |
||||
'bias_initializer': {'class_name': 'Zeros', 'config': {}}, |
||||
'kernel_regularizer': None, |
||||
'bias_regularizer': None, |
||||
'activity_regularizer': None, |
||||
'kernel_constraint': None, |
||||
'bias_constraint': None} |
||||
``` |
||||
``` |
||||
{'name': 'dense_8', |
||||
'trainable': True, |
||||
'dtype': 'float32', |
||||
'units': 4, |
||||
'activation': 'sigmoid', |
||||
'use_bias': True, |
||||
'kernel_initializer': {'class_name': 'GlorotUniform', |
||||
'config': {'seed': None}}, |
||||
'bias_initializer': {'class_name': 'Zeros', 'config': {}}, |
||||
'kernel_regularizer': None, |
||||
'bias_regularizer': None, |
||||
'activity_regularizer': None, |
||||
'kernel_constraint': None, |
||||
'bias_constraint': None} |
||||
``` |
||||
##### The question 3 is validated if the fields `units` and `activation` match this output: |
||||
|
||||
``` |
||||
{'name': 'dense_9', |
||||
'trainable': True, |
||||
'dtype': 'float32', |
||||
'units': 1, |
||||
'activation': 'sigmoid', |
||||
'use_bias': True, |
||||
'kernel_initializer': {'class_name': 'GlorotUniform', |
||||
'config': {'seed': None}}, |
||||
'bias_initializer': {'class_name': 'Zeros', 'config': {}}, |
||||
'kernel_regularizer': None, |
||||
'bias_regularizer': None, |
||||
'activity_regularizer': None, |
||||
'kernel_constraint': None, |
||||
'bias_constraint': None} |
||||
``` |
||||
|
@ -1,11 +1,11 @@
|
||||
1. This question is validated if the code that creates the neural network is: |
||||
##### The question 1 is validated if the code that creates the neural network is: |
||||
|
||||
``` |
||||
model = keras.Sequential() |
||||
model.add(Dense(8, input_shape=(5,), activation= 'sigmoid')) |
||||
model.add(Dense(4, activation= 'sigmoid')) |
||||
model.add(Dense(1, activation= 'linear')) |
||||
``` |
||||
model = keras.Sequential() |
||||
model.add(Dense(8, input_shape=(5,), activation= 'sigmoid')) |
||||
model.add(Dense(4, activation= 'sigmoid')) |
||||
model.add(Dense(1, activation= 'linear')) |
||||
|
||||
``` |
||||
``` |
||||
|
||||
The first two layers could use another activation function that sigmoid (eg: relu) |
@ -1,9 +1,8 @@
|
||||
1. This question is validated if the code that creates the neural network is: |
||||
##### The question 1 is validated if the code that creates the neural network is: |
||||
|
||||
``` |
||||
model = keras.Sequential() |
||||
model.add(Dense(16, input_shape=(5,), activation= 'sigmoid')) |
||||
model.add(Dense(8, activation= 'sigmoid')) |
||||
model.add(Dense(5, activation= 'softmax')) |
||||
|
||||
``` |
||||
``` |
||||
model = keras.Sequential() |
||||
model.add(Dense(16, input_shape=(5,), activation= 'sigmoid')) |
||||
model.add(Dense(8, activation= 'sigmoid')) |
||||
model.add(Dense(5, activation= 'softmax')) |
||||
``` |
@ -1,8 +1,8 @@
|
||||
1. This question is validated if the similarities between the sentences are: |
||||
##### The question 1 is validated if the similarities between the sentences are: |
||||
|
||||
``` |
||||
sentence_1 <=> sentence 2 : 0.7073220863266589 |
||||
sentence_1 <=> sentence 3: 0.42663743263528325 |
||||
sentence_2 <=> sentence 3: 0.3336274235605957 |
||||
``` |
||||
sentence_1 <=> sentence 2 : 0.7073220863266589 |
||||
sentence_1 <=> sentence 3: 0.42663743263528325 |
||||
sentence_2 <=> sentence 3: 0.3336274235605957 |
||||
|
||||
``` |
||||
``` |
||||
|
@ -1,18 +1,18 @@
|
||||
1. This question is validated if the sentences outputed are: |
||||
##### The question 1 is validated if the sentences outputed are: |
||||
|
||||
``` |
||||
INFO: Bezos PROPN NNP |
||||
Sentence: Amazon (AMZN) enters 2021 with plenty of big opportunities, but is losing its lauded Chief Executive Jeff Bezos, who announced his plan to step aside in the third quarter. |
||||
``` |
||||
INFO: Bezos PROPN NNP |
||||
Sentence: Amazon (AMZN) enters 2021 with plenty of big opportunities, but is losing its lauded Chief Executive Jeff Bezos, who announced his plan to step aside in the third quarter. |
||||
|
||||
|
||||
INFO: Bezos PROPN NNP |
||||
Sentence: Bezos will hand off his role as chief executive to Andy Jassy, the CEO of its cloud computing unit. |
||||
INFO: Bezos PROPN NNP |
||||
Sentence: Bezos will hand off his role as chief executive to Andy Jassy, the CEO of its cloud computing unit. |
||||
|
||||
|
||||
INFO: Bezos PROPN NNP |
||||
Sentence: He's not leaving, as Bezos will transition to the role of Executive Chairman and remain active. |
||||
INFO: Bezos PROPN NNP |
||||
Sentence: He's not leaving, as Bezos will transition to the role of Executive Chairman and remain active. |
||||
|
||||
|
||||
INFO: Bezos PROPN NNP |
||||
Sentence: "When you look at our financial results, what you're actually seeing are the long-run cumulative results of invention," Bezos said in written remarks with the Amazon earnings release. |
||||
``` |
||||
INFO: Bezos PROPN NNP |
||||
Sentence: "When you look at our financial results, what you're actually seeing are the long-run cumulative results of invention," Bezos said in written remarks with the Amazon earnings release. |
||||
``` |
Loading…
Reference in new issue