2. Hello again!
In the last we did an overview about
ML, it’s types and applications, today
we will dive in the python programming
language to use it to develop ML
models. Get your machine ready .
2
8. String
8
status = ‘Kirak dayer’
String can be declared as following:
name = "Charfaoui Younes"
This is also the same thing:
phrase = status + name
This is concatenation
9. Number
9
number = str(12.5)
Integer numbers
year = 2018
year = int("2019")
You can also convert
from number to string
n_type = type(number)
To Check the type of
variable use type()
Floating numbers
pi = 3.141592
pi = float("3.141592")
12. List (Arrays)
12
In Python List can be heterogenous
favorites = []
favorites.append(21)
favorites.append(“MLBC”)
favorites.append(True)
Adding things in List
favorites = [21 , “MLBC” , True]
Equivalent to
15. Arithmetic
15
a = 10 # 10
a += 1 # 11
a -= 2 # 9
b = a + 1 # 10
c = b – 3 # 7
d = a * 2 # 18
e = d /2 # 9
f = e % 2 # 1
g = e ** 2 # 81
i = g // 2 # 40
20. Conditionals
20
grade = 82
if grade >= 90:
if grade == 100:
print ("A+")
else:
print ("A")
elif grade >= 80:
print ("B")
elif grade >= 70:
print ("C")
else:
print ("F")
The Indentation is
considered to be
replacement of brackets
here in python, so be
carful for your spaces
21. For Loop
21
for x in range(10):
print(x)
persons = [“Zoubir” , “Younes”]
for x in persons :
print(x)
33. Numpy
33
http://www.numpy.org/
NumPy is the fundamental package for scientific computing
with Python. It contains among other things:
• a powerful N-dimensional array object
• sophisticated (broadcasting) functions
• useful linear algebra, Fourier transform, and random
number capabilities
35. Pandas
35
https://pandas.pydata.org/
Pandas is an open source, BSD-licensed
library providing high-performance, easy-to-
use data structures and data analysis tools
for the Python programming language.
36. Matplotlib
36
Matplotlib is a Python 2D plotting library which produces
publication quality figures in a variety of hardcopy formats
and interactive environments across platforms. Matplotlib can
be used in Python scripts, the Python and IPython shells, the
Jupyter notebook, web application servers, and four graphical
user interface toolkits.
https://matplotlib.org/
39. 39
Coding Interview
Given an array of time intervals (start, end) for classroom
lectures (possibly overlapping), find the minimum number
of rooms required.
For example, given [(30, 75), (0, 50), (60, 150)], you should
return 2.