Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Pool 2024 #16

Merged
merged 29 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f60226a
ai day2 module1: linear regression
agherasie Nov 11, 2023
1c01c41
ai: removed answers and added pandas exercise
agherasie Nov 11, 2023
9a711c5
ai: removed pandas exercise correction
agherasie Nov 11, 2023
0124085
ai: using forward() in last method
agherasie Nov 11, 2023
b7d38d9
wip: logistic regression
agherasie Nov 25, 2023
c6e12d7
wip: markdown logistic regression
agherasie Nov 26, 2023
061955f
ai/day4: added 2023 content from day5
agherasie Nov 26, 2023
ce6e745
feat: logistic regression
agherasie Dec 24, 2023
2f806d4
feat: deep learning
agherasie Dec 24, 2023
7002d6e
feat: added links to readme
agherasie Dec 24, 2023
b91a4b9
fix: removed answers
agherasie Dec 24, 2023
05bfd6c
init: day5
agherasie Jan 18, 2024
9592df0
[ADD] First part d1 and d3
MatthiasvonRakowski Feb 4, 2024
7cb7100
feat: nlp module from last year
agherasie Feb 4, 2024
44f77c2
Merge pull request #1 from PoCInnovation/ai/day-2
agherasie Feb 4, 2024
e25ab5a
[ADD] d1
MatthiasvonRakowski Feb 5, 2024
d5ff943
feat: gnn write up
agherasie Feb 11, 2024
8e34d61
fix: readme
agherasie Feb 11, 2024
c894e06
[ADD] Day03
MatthiasvonRakowski Feb 11, 2024
34ff59b
Merge branch 'ai/day5-nlp' into ai/day5-gnn
agherasie Feb 11, 2024
cf9678d
Merge pull request #21 from PoCInnovation/ai/day5-gnn
agherasie Feb 11, 2024
136c82c
Merge pull request #15 from PoCInnovation/ai/day5-nlp
MatthiasvonRakowski Feb 11, 2024
83ca089
[DELETE] day4
MatthiasvonRakowski Feb 11, 2024
c027c45
[ADD] README day1
MatthiasvonRakowski Feb 11, 2024
4341544
Update README.md
agherasie Feb 11, 2024
f19c4b0
Merge pull request #23 from PoCInnovation/fix/readme-day4-ai
agherasie Feb 11, 2024
5ffcba5
Merge pull request #22 from PoCInnovation/ai/day-1
MatthiasvonRakowski Feb 11, 2024
396bda5
fix: day folder names
agherasie Feb 11, 2024
628a9c9
Merge pull request #24 from PoCInnovation/fix/day-folder-names
agherasie Feb 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,084 changes: 1,084 additions & 0 deletions AI/day01/1 - python/Python.ipynb

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletions AI/day01/1 - python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Module 1: Python

Welcome and thank you for participating in the Artificial Intelligence Pool by PoC Innovation ! Our team has worked hard to create a great learning resource and introduction to the incredible world of Artificial Intelligence and what better way to start than the most popular programming language for Machine Learning - **Python** !

During this week, you will use Python to tackle Machine Learning subjects of increasing difficulty, so never hesitate to ask the PoC staff for help, they'll be happy to answer your questions and don't worry about not completing each Pool Day: **the subjects are difficult to finish by design** !

Ultimately, the goal is for you to achieve a good knowledge of the field of AI after this week. So make sure you take your time to truly grasp the concepts you will see throughout this course. **Learning AI is not something you can rush; so make sure you understand the theory behind what you do during this Pool**.

Now, buckle up: **your adventure begins now** !


## Python3

Python is a high-level interpreted language, which has become very popular in the academic and scientific community for its simplicity and its layer of abstraction of several rules of computer science, such as the fact that you don't need to type your variables. Python is also able to interpret different programming paradigms like imperative, object-oriented...

So you may ask yourself: Why do we use Python which is slower than C/C++ for AI, a domain that requires a lot of resources?
Well, quite simply, libraries like TensorFlow work with a Python interface on the surface but use the C++ language behind.

### Example

> "Hello World" Function

```py
def myFunc(name="Undefined"):
""" A function is defined using the keyword `def` followed by a space
and the name of the function, between brackets we put the different parameters
for the example we have the parameter `name` which by default is equal to Undefined.
This comment is called a docstring: it provides a way for developers to explain the usage of a function / class / etc. so that other developers can understand how to use them. For a function, you'll generally find the required arguments as well as the returned values and maybe some usage examples.

Args:
name: name of the user

Returns:
None
"""
print("Hello " + name)

# myFunc() will display "Hello Undefined"
# myFunc("PoC") will display "Hello PoC"

```

## Python Command Line

Before we get started with **iPython notebooks**, which you will be using for most of the week, we'd like to show you a cool party trick that you can do using any terminal with Python installed !

Open up a new terminal window: inside, simply run the `python` command !

```bash
> python
```

This command will open up the python command line:

```bash
> python
Python 3.X.XX (main, XXX XX XXXX, XX:XX:XX)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
```

The output **will** differ based on your Python version and other variables but it **should** open a command line where you can execute any python code !

That's right: you can even build an entire neural network inside this command line (although we **will** be very scared if you choose to do so)

Of course, you will not be writing your code inside this command line very often, because most of the time, you wish to save your code inside a `.py` or `.ipynb` file 😄.

However, this command line can help you troubleshoot your code in a smaller scope.

You can try using the `print()` method to print some stuff on your terminal.

```bash
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello world")
Hello world
>>>
```

Pretty cool, right ? What if you instead want to know what the result of 2 + 2 is ?

```bash
Type "help", "copyright", "credits" or "license" for more information.
>>> print(2 + 2)
4
>>> a = 2 + 2
>>> print(a)
4
>>> 2 + 2
4
>>>
```

Interesting... these three inputs have the same output, "4".

One of them uses the `print()` method, the other stores 2 + 2 inside a and then prints it and the last one only calculates 2 + 2 but still, the output is 4 despite the fact that we didn't even ask Python to display the result !

Try to open your own Python command line and run your own experiments to see what's happening.

In python, the result of each line of code is displayed in the console. This behaviour is particularly useful for visualisation inside Jupyter Notebooks, which we will talk about just after this small explanation of data types:

## Python Data Types

But the last result being displayed might not be the only thing that surprised you with how python works.

Many of you might be familiar with the C language and its `printf()` function. In C, in order to print the result of 2 + 2, you would need to do the following:

```c
printf("%i\n", 2 + 2);
```

In python, it's enough to just do:

```py
print(2 + 2)
```

Why is that ? Well, python is both a strongly and dynamically typed language:

| Typing | Static | Dynamic |
| -------- | --------- | --------- |
| Variable | typed | not typed |
| Value | not typed | typed |

| Typing | Strong | Weak | Strong & Dynamic |
| -------------- | ------ | ---- | ---------------- |
| "I am " + 13 | ❌ | ✅ | ✅ |
| "I am " + "13" | ✅ | ✅ | ✅ |

Static typing (for example C) means that variables have a type which must be known by the interpretor from the moment the variable is declared.\
Dynamic (for example JavaScript) typing means that values / objects have types which can be changed at any given time.

Strong typing (C) means that you can not perform operations between different types of variables.\
Weak typing (JavaScript) means that you can perform any operation between any types of variables.

A strongly and dynamically typed language (Python) allows the developer to benefit from dynamic typing but still has the safety provided by strong typing.

You can open a Python command line and use the `type()` method to check out the different data types for each value:

```bash
>>> type(1)
<class 'int'>
>>> type("hello world")
<class 'str'>
>>>
```

Before heading over to the `.ipynb` notebook, please fill in and submit a file called `data_types.txt` which contains the corresponding built-in types for the following values in order:

- 1
- "hello world"
- 1.0
- ["apples", "oranges", "bananas"]
- {"answer": 42}
- 2 + 2 == 4
- None

Simply write the output of `type()` for each of the above values in order, one by line.

```bash
❯ cat data_types.txt -e
<class 'int'>$
<class 'str'>$
```

## Submit 🏆

- Fill the `data_types.txt` file with the required data types.

- Fill the ``Python.ipynb`` notebook.

To submit your work, think about pushing your changes. It is important to push so that we are able to assess participation.
If you have any concerns, talk to a supervisor.

## Resources

- [Python3 Documentation](https://docs.python.org/3/)
- [Why Python3 more than C++ ?](https://fr.quora.com/Pourquoi-Python-est-tr%C3%A8s-utilis%C3%A9-en-IA-Big-Data-alors-quil-nest-pas-le-plus-performant-en-rapidit%C3%A9-de-calcul)
- [Python3 courses](https://courspython.com/introduction-python.html)
- [Python3 Machine Learnia](https://www.youtube.com/watch?v=82KLS2C_gNQ)
3 changes: 3 additions & 0 deletions AI/day01/1 - python/data_types.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
value,data type
1,int
hello world,str
2 changes: 2 additions & 0 deletions AI/day01/1 - python/data_types.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int
str
Binary file added AI/day01/1 - python/images/diagramme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AI/day01/1 - python/images/listvstuplevsset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AI/day01/1 - python/images/python.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions AI/day01/2 - numpy_matplotlib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Module 2 : NumPy & Matplotlib

Welcome to this second module young student, you are now comfortable with Python it is time to enter the world of data science.

In that section we will learn about the NumPy library and the Matplotlib library.

## NumPy

NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.
It is the fundamental package for scientific computing with Python. A little exemple to illustrate the power of NumPy:

![NumpyArray.png](assets/NumpyArray.png)

In the image above, we can see that is really easy to create a multi-dimensional matrix, and now, we will see, also why it is also really simple to make operation on this array with numpy.
For example if we want to take the transpose of the array, we just have to do:

```python
import numpy as np

arr = np.array([[1, 2, 3, 3], [4, 5, 2, 8], [7, 8, 9, 13], [10, 11, 12, 15]])
arr = arr.T
```

now if we want to have all number in the diagonal, we just have to do:

```python
arr.diagonal()
```

Those are easy example, but we can do way more, but you will see it in the exercices.

## Matplotlib

Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy.
It is in fact to show the data that we will manipulate with NumPy, and it is really easy to use, for example if we want to plot a simple graph, we just have to do:

```python
import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [2, 3, 4, 5, 6]

plt.plot(x, y)
plt.show()
```

We just create a line who is based on the fonction y = x + 1, and we can see that it is really simple to do, of course we can do way more,
but you will see it in the exercices.

## Submit 🏆

Fill the notebook: ``numpy_matplotlib.ipynb``

To submit your work, think about pushing your changes. It is important to push so that we are able to assess participation.
If you have any concerns, talk to a supervisor.

## Resources :book:

- [Doc NumPy](https://numpy.org/doc/stable/)
- [Doc Matplotlib](https://matplotlib.org/stable/contents.html)
Binary file added AI/day01/2 - numpy_matplotlib/assets/Matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading