SlideShare a Scribd company logo
Introduction to
Machine Learning
(5 ECTS)
Giovanni Di Liberto
Asst. Prof. in Intelligent Systems, SCSS
Room G.15, O’Reilly Institute ©Trinity College Dublin
Trinity College Dublin, The University of Dublin 2
Data
Trinity College Dublin, The University of Dublin 3
Internet Data in 60 seconds
Either download or upload (generate) data
Trinity College Dublin, The University of Dublin
Big data
4
Why now?
GB
242 kB 1.44MB
(x1000000 the
size of an old
floppy disk)
Much more!!
Also, algorithms that can deal with and learn from such large datasets
Trinity College Dublin, The University of Dublin 5
Introduction to Programming
A computer needs instructions to do anything!
No instructions -> expensive ornament
Trinity College Dublin, The University of Dublin
Introduction to Programming
6
What is a programming language?
- A programming language is a set of instructions, delivered according to a particular syntax, that
can be used to create a software program.
- In this module we will use Python.
- Like spoken languages, programming languages have rules, such as syntax, that must be learnt.
- Hands-on learning is the best way to learn a new programming language, so write lots of code!
Trinity College Dublin, The University of Dublin
Introduction to Programming
7
- Typical programming languages are called "high-level languages“. This code can be compiled into
a "low-level language," which is recognized directly by the computer hardware
High-level languages
• Easy for humans to learn and use
• E.g., C, C++, Python
• The machine does not understand
these languages directly
Low-level languages
• The machine (e.g., laptop,
smartphone) understands it
• Full control on what the
machine does exactly
Translation step
Trinity College Dublin, The University of Dublin
Introduction to Programming
8
High-level language -> Translation step -> Low-level (machine) language
Translate all code in one go
Create executables (e.g., .exe in
windows; the file you use to launch
an app on your phone) and use
them on any compatible machine
Translate the code one step at a
time. The interpreter is required to
run the software on a machine.
Challenge: the low-level instructions may
change between different types of
machine (e.g., different CPU, laptop vs.
smartphone, different OS)
COMPILED LANGUAGES
e.g., Pascal, C++
INTERPRETED LANGUAGES
e.g., Python, Matlab
This distinction used to be very important.
It’s less important now.
Trinity College Dublin, The University of Dublin 9
Programming languages timeline
Trinity College Dublin, The University of Dublin 10
Trinity College Dublin, The University of Dublin 11
Why Python?
Like with a spoken language, we may like a language because it sounds nicer
than another one. Or because we like the alphabet, or maybe because it is
easier to learn for us because it is closer to another language we know.
What we should focus on is “what we can do with it”!
• Amazing set of libraries/tools for ML
• Rich online resources
• Open-source and free!
Trinity College Dublin, The University of Dublin 12
What can we do with Python?
Spotify’s backend consists of many
interdependent services, connected by [its]
own messaging protocol over ZeroMQ.
Around 80% of these services are written in
Python.
It all got started, I believe, because the very earliest
Googlers (Sergey, Larry, Craig, …) made a good
engineering decision: “Python where we can, C++
where we must.”
Trinity College Dublin, The University of Dublin 13
https://jupyter-notebook.readthedocs.io/en/stable/
https://jupyter.readthedocs.io/en/latest/install/notebook-classic.html
https://anaconda.cloud/tutorials/getting-started-with-anaconda-individual-edition?source=win_installer
Setting up your coding environment
- Windows or Mac OS: run Anaconda Navigator from
the Start menu or application menu
- In Linux: run anaconda-navigator from the terminal
Trinity College Dublin, The University of Dublin 14
Anaconda distribution
It installs many packages (libraries and applications) that are useful for ML
Trinity College Dublin, The University of Dublin 15
Anaconda distribution
Trinity College Dublin, The University of Dublin 16
Anaconda distribution
Trinity College Dublin, The University of Dublin 17
Introduction to programming
Pseudocode
PROGRAM makeACupOfTea
IF kettle unplugged
Plug in kettle
END
put water into kettle
press kettle button for boiling water
search for teabag
select teabag
IF teabag is missing
go away disappointed
END
WAIT for water to boil
add water to cup
add teabag to cup
WAIT for the desired time
remove teabag with spoon/fork
add milk or lemon
serve
END camelCase vs snake_case
Trinity College Dublin, The University of Dublin 18
Introduction to programming
Pseudocode
ITERATE
WAIT for input x # x can be +1 (incoming bike) or -1 (bike taken)
IF x == 1
availableStands = availableStands-1
availableBikes = availableBikes+1
ELSEIF x == -1
availableStands = availableStands+1
availableBikes = availableBikes-1
END
END
Indentation, comments, variables, conditions
Trinity College Dublin, The University of Dublin 19
Introduction to programming
Pseudocode
ITERATE
WAIT for input x # x can be +1 (incoming bike) or -1 (bike taken)
availableStands = availableStands-x
availableBikes = availableBikes+x
END
Indentation, comments, variables, conditions
Trinity College Dublin, The University of Dublin 20
Introduction to programming
Pseudocode
ITERATE
WAIT for input x # x can be +1 (incoming bike) or -1 (bike taken)
IF availableStands-x < 0 OR availableStands-x > MAX_STANDS
ERROR
ELSE
availableStands = availableStands-x
availableBikes = availableBikes+x
END
END
Indentation, comments, variables, conditions
Trinity College Dublin, The University of Dublin 21
Code examples
https://github.com/ageron/handson-ml2
https://colab.research.google.com/github/ageron/handson-
ml2/blob/master/
From the book “Hands-On Machine Learning with Scikit-Learn,
Keras, and TensorFlow”, Aurélien Géron, 2019
We will also upload our own code on the blackboard
Trinity College Dublin, The University of Dublin 22
Introduction to programming
Code: print(“Hello world!”)
Output: Hello world!
Comments # This is a comment
Variables (types) x1 = 5
x2 = “I am a string”
x3 = 3/2
# String concatenation
string1 = "Linux"
string2 = "Hint"
joined_string = string1 + string2
print(joined_string)
Calculating 43
import math
# Assign values to x and n
x = 4
n = 3
# Method 1
power = x ** n
print("%d to the power %d is %d" % (x,n,power))
# Method 2
power = pow(x,n)
print("%d to the power %d is %d" % (x,n,power))
# Method 3
power = math.pow(2,6.5)
print("%d to the power %d is %5.2f" % (x,n,power))
Trinity College Dublin, The University of Dublin 23
Introduction to programming
Not just a calculator!
If statement, For loop, Functions
import datetime as dt
hourNow = dt.datetime.now().hour
# Check if the post office is open
if (hourNow >= 8 and hourNow <= 18):
print(“Open")
else:
print(“Closed")
# Alternatively
# if (hourNow in range(8,19))
# Boolean value
val1 = True
print(val1)
# Number to Boolean
number = 10
print(bool(number))
number = -5
print(bool(number))
number = 0
print(bool(number))
# Boolean from comparison operator
val1 = 6
val2 = 3
print(val1 < val2)
True
True
True
False
False
Trinity College Dublin, The University of Dublin 24
Introduction to programming
Not just a calculator!
If statement, For loop, Functions, Classes
x = range(6)
for n in x:
print(n)
# Boolean value
val1 = True
print(val1)
# Number to Boolean
number = 10
print(bool(number))
number = -5
print(bool(number))
number = 0
print(bool(number))
# Boolean from comparison operator
val1 = 6
val2 = 3
print(val1 < val2)
True
True
True
False
False
Trinity College Dublin, The University of Dublin 25
More about coding
Good code needs little comments. But use comments!
Choose meaningful variable names.
My advice: Top-down coding style
Start by organizing the sections by using pseudocode as comments
# This script prints whether a Dublin-bike station has available bikes now
# Loads the Dublin-bikes real-time dataset
# Ask user which bike station they want to look into
# Extract the most recent information about the station of interest
# If the column ‘Available Bikes’ is greater than zero, then print “Yes”
# Else print “No”
Trinity College Dublin, The University of Dublin 26
More about coding
Good code needs little commenting. But use comments!
Choose meaningful variable names.
My advice: Top-down coding style
Start by organizing the sections by using pseudocode as comments
Then start writing each section
# This script prints whether a Dublin-bike station has available bikes now
# Loads the Dublin-bikes real-time dataset
loadataset = pandas.read_csv("dublinbikes_2021Q1.csv")
# Ask user which bike station they want to look into
val = input("Enter the station name: ")
# Extract the most recent information about the station of interest
# If the column ‘Available Bikes’ is greater than zero, then print “Yes”
# Else print “No”
Trinity College Dublin, The University of Dublin 27

More Related Content

Similar to IntroML_2.

C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
Danielle780357
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
Pratima Parida
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
Pratima Parida
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
Marcel Bruch
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
AnassElHousni
 
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
Thinkful
 
Java
JavaJava
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
Zeeshan MIrza
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
ナム-Nam Nguyễn
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it security
CESAR A. RUIZ C
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
Tharindu Weerasinghe
 
The genesis of clusterlib - An open source library to tame your favourite sup...
The genesis of clusterlib - An open source library to tame your favourite sup...The genesis of clusterlib - An open source library to tame your favourite sup...
The genesis of clusterlib - An open source library to tame your favourite sup...
Arnaud Joly
 
structured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsstructured programming Introduction to c fundamentals
structured programming Introduction to c fundamentals
OMWOMA JACKSON
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
Martin Odersky
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
olracoatalub
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
Katy Allen
 
Continuous Security in DevOps
Continuous Security in DevOpsContinuous Security in DevOps
Continuous Security in DevOps
Maciej Lasyk
 
4Developers 2015: Continuous Security in DevOps - Maciej Lasyk
4Developers 2015: Continuous Security in DevOps - Maciej Lasyk4Developers 2015: Continuous Security in DevOps - Maciej Lasyk
4Developers 2015: Continuous Security in DevOps - Maciej Lasyk
PROIDEA
 
Proyect of english
Proyect of englishProyect of english
Proyect of english
Carlos Alcivar
 
ch01-basic-java-programs.ppt
ch01-basic-java-programs.pptch01-basic-java-programs.ppt
ch01-basic-java-programs.ppt
Mahyuddin8
 

Similar to IntroML_2. (20)

C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
pdx893ff61f-1fb8-4e15-a379-775dfdbcee77-7-14-26-112
 
Java
JavaJava
Java
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it security
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
The genesis of clusterlib - An open source library to tame your favourite sup...
The genesis of clusterlib - An open source library to tame your favourite sup...The genesis of clusterlib - An open source library to tame your favourite sup...
The genesis of clusterlib - An open source library to tame your favourite sup...
 
structured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsstructured programming Introduction to c fundamentals
structured programming Introduction to c fundamentals
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
 
Continuous Security in DevOps
Continuous Security in DevOpsContinuous Security in DevOps
Continuous Security in DevOps
 
4Developers 2015: Continuous Security in DevOps - Maciej Lasyk
4Developers 2015: Continuous Security in DevOps - Maciej Lasyk4Developers 2015: Continuous Security in DevOps - Maciej Lasyk
4Developers 2015: Continuous Security in DevOps - Maciej Lasyk
 
Proyect of english
Proyect of englishProyect of english
Proyect of english
 
ch01-basic-java-programs.ppt
ch01-basic-java-programs.pptch01-basic-java-programs.ppt
ch01-basic-java-programs.ppt
 

Recently uploaded

Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Leena Ghag-Sakpal
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 

Recently uploaded (20)

Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 

IntroML_2.

  • 1. Introduction to Machine Learning (5 ECTS) Giovanni Di Liberto Asst. Prof. in Intelligent Systems, SCSS Room G.15, O’Reilly Institute ©Trinity College Dublin
  • 2. Trinity College Dublin, The University of Dublin 2 Data
  • 3. Trinity College Dublin, The University of Dublin 3 Internet Data in 60 seconds Either download or upload (generate) data
  • 4. Trinity College Dublin, The University of Dublin Big data 4 Why now? GB 242 kB 1.44MB (x1000000 the size of an old floppy disk) Much more!! Also, algorithms that can deal with and learn from such large datasets
  • 5. Trinity College Dublin, The University of Dublin 5 Introduction to Programming A computer needs instructions to do anything! No instructions -> expensive ornament
  • 6. Trinity College Dublin, The University of Dublin Introduction to Programming 6 What is a programming language? - A programming language is a set of instructions, delivered according to a particular syntax, that can be used to create a software program. - In this module we will use Python. - Like spoken languages, programming languages have rules, such as syntax, that must be learnt. - Hands-on learning is the best way to learn a new programming language, so write lots of code!
  • 7. Trinity College Dublin, The University of Dublin Introduction to Programming 7 - Typical programming languages are called "high-level languages“. This code can be compiled into a "low-level language," which is recognized directly by the computer hardware High-level languages • Easy for humans to learn and use • E.g., C, C++, Python • The machine does not understand these languages directly Low-level languages • The machine (e.g., laptop, smartphone) understands it • Full control on what the machine does exactly Translation step
  • 8. Trinity College Dublin, The University of Dublin Introduction to Programming 8 High-level language -> Translation step -> Low-level (machine) language Translate all code in one go Create executables (e.g., .exe in windows; the file you use to launch an app on your phone) and use them on any compatible machine Translate the code one step at a time. The interpreter is required to run the software on a machine. Challenge: the low-level instructions may change between different types of machine (e.g., different CPU, laptop vs. smartphone, different OS) COMPILED LANGUAGES e.g., Pascal, C++ INTERPRETED LANGUAGES e.g., Python, Matlab This distinction used to be very important. It’s less important now.
  • 9. Trinity College Dublin, The University of Dublin 9 Programming languages timeline
  • 10. Trinity College Dublin, The University of Dublin 10
  • 11. Trinity College Dublin, The University of Dublin 11 Why Python? Like with a spoken language, we may like a language because it sounds nicer than another one. Or because we like the alphabet, or maybe because it is easier to learn for us because it is closer to another language we know. What we should focus on is “what we can do with it”! • Amazing set of libraries/tools for ML • Rich online resources • Open-source and free!
  • 12. Trinity College Dublin, The University of Dublin 12 What can we do with Python? Spotify’s backend consists of many interdependent services, connected by [its] own messaging protocol over ZeroMQ. Around 80% of these services are written in Python. It all got started, I believe, because the very earliest Googlers (Sergey, Larry, Craig, …) made a good engineering decision: “Python where we can, C++ where we must.”
  • 13. Trinity College Dublin, The University of Dublin 13 https://jupyter-notebook.readthedocs.io/en/stable/ https://jupyter.readthedocs.io/en/latest/install/notebook-classic.html https://anaconda.cloud/tutorials/getting-started-with-anaconda-individual-edition?source=win_installer Setting up your coding environment - Windows or Mac OS: run Anaconda Navigator from the Start menu or application menu - In Linux: run anaconda-navigator from the terminal
  • 14. Trinity College Dublin, The University of Dublin 14 Anaconda distribution It installs many packages (libraries and applications) that are useful for ML
  • 15. Trinity College Dublin, The University of Dublin 15 Anaconda distribution
  • 16. Trinity College Dublin, The University of Dublin 16 Anaconda distribution
  • 17. Trinity College Dublin, The University of Dublin 17 Introduction to programming Pseudocode PROGRAM makeACupOfTea IF kettle unplugged Plug in kettle END put water into kettle press kettle button for boiling water search for teabag select teabag IF teabag is missing go away disappointed END WAIT for water to boil add water to cup add teabag to cup WAIT for the desired time remove teabag with spoon/fork add milk or lemon serve END camelCase vs snake_case
  • 18. Trinity College Dublin, The University of Dublin 18 Introduction to programming Pseudocode ITERATE WAIT for input x # x can be +1 (incoming bike) or -1 (bike taken) IF x == 1 availableStands = availableStands-1 availableBikes = availableBikes+1 ELSEIF x == -1 availableStands = availableStands+1 availableBikes = availableBikes-1 END END Indentation, comments, variables, conditions
  • 19. Trinity College Dublin, The University of Dublin 19 Introduction to programming Pseudocode ITERATE WAIT for input x # x can be +1 (incoming bike) or -1 (bike taken) availableStands = availableStands-x availableBikes = availableBikes+x END Indentation, comments, variables, conditions
  • 20. Trinity College Dublin, The University of Dublin 20 Introduction to programming Pseudocode ITERATE WAIT for input x # x can be +1 (incoming bike) or -1 (bike taken) IF availableStands-x < 0 OR availableStands-x > MAX_STANDS ERROR ELSE availableStands = availableStands-x availableBikes = availableBikes+x END END Indentation, comments, variables, conditions
  • 21. Trinity College Dublin, The University of Dublin 21 Code examples https://github.com/ageron/handson-ml2 https://colab.research.google.com/github/ageron/handson- ml2/blob/master/ From the book “Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow”, Aurélien Géron, 2019 We will also upload our own code on the blackboard
  • 22. Trinity College Dublin, The University of Dublin 22 Introduction to programming Code: print(“Hello world!”) Output: Hello world! Comments # This is a comment Variables (types) x1 = 5 x2 = “I am a string” x3 = 3/2 # String concatenation string1 = "Linux" string2 = "Hint" joined_string = string1 + string2 print(joined_string) Calculating 43 import math # Assign values to x and n x = 4 n = 3 # Method 1 power = x ** n print("%d to the power %d is %d" % (x,n,power)) # Method 2 power = pow(x,n) print("%d to the power %d is %d" % (x,n,power)) # Method 3 power = math.pow(2,6.5) print("%d to the power %d is %5.2f" % (x,n,power))
  • 23. Trinity College Dublin, The University of Dublin 23 Introduction to programming Not just a calculator! If statement, For loop, Functions import datetime as dt hourNow = dt.datetime.now().hour # Check if the post office is open if (hourNow >= 8 and hourNow <= 18): print(“Open") else: print(“Closed") # Alternatively # if (hourNow in range(8,19)) # Boolean value val1 = True print(val1) # Number to Boolean number = 10 print(bool(number)) number = -5 print(bool(number)) number = 0 print(bool(number)) # Boolean from comparison operator val1 = 6 val2 = 3 print(val1 < val2) True True True False False
  • 24. Trinity College Dublin, The University of Dublin 24 Introduction to programming Not just a calculator! If statement, For loop, Functions, Classes x = range(6) for n in x: print(n) # Boolean value val1 = True print(val1) # Number to Boolean number = 10 print(bool(number)) number = -5 print(bool(number)) number = 0 print(bool(number)) # Boolean from comparison operator val1 = 6 val2 = 3 print(val1 < val2) True True True False False
  • 25. Trinity College Dublin, The University of Dublin 25 More about coding Good code needs little comments. But use comments! Choose meaningful variable names. My advice: Top-down coding style Start by organizing the sections by using pseudocode as comments # This script prints whether a Dublin-bike station has available bikes now # Loads the Dublin-bikes real-time dataset # Ask user which bike station they want to look into # Extract the most recent information about the station of interest # If the column ‘Available Bikes’ is greater than zero, then print “Yes” # Else print “No”
  • 26. Trinity College Dublin, The University of Dublin 26 More about coding Good code needs little commenting. But use comments! Choose meaningful variable names. My advice: Top-down coding style Start by organizing the sections by using pseudocode as comments Then start writing each section # This script prints whether a Dublin-bike station has available bikes now # Loads the Dublin-bikes real-time dataset loadataset = pandas.read_csv("dublinbikes_2021Q1.csv") # Ask user which bike station they want to look into val = input("Enter the station name: ") # Extract the most recent information about the station of interest # If the column ‘Available Bikes’ is greater than zero, then print “Yes” # Else print “No”
  • 27. Trinity College Dublin, The University of Dublin 27