penn engineering | inventing the futurecis192/jorge/slides/01_introduction.pdfwit.ai image-to-image...
TRANSCRIPT
![Page 1: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/1.jpg)
CIS 192Python programmingInstructor: Jorge Mendez
http://www.seas.upenn.edu/~cis192/jorge/
![Page 2: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/2.jpg)
About me
Born and raised in Caracas, Venezuela
Electrical Engineer by background
4th year CIS PhD student with Eric Eaton at Lifelong Machine Learning group
![Page 3: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/3.jpg)
My path with Python
Senior year in collegeImage processing project
2014
At PennDay-to-day research
2016
SummerData Science internship at Capital One
2017
SummerResearch internship at Facebook
2019
![Page 4: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/4.jpg)
Why learn Python?
It is simple, yet powerful
Data science and machine learning
Web development
Tons of libraries and frameworks
Huge job market
Great salaries
![Page 5: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/5.jpg)
Hello world!
Python Java C++
print('Hello world!') class HelloWorld{
public static void main(String args[]){
System.out.println("Hello world!");}
}
#include<iostream>
using namespace std; int main() {
cout << "Hello world!"; return 0;
}
![Page 6: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/6.jpg)
Why learn Python?
It is simple, yet powerful
Data science and machine learning
Web development
Tons of libraries and frameworks
Huge job market
Great salaries
![Page 7: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/7.jpg)
Data analysis and visualization
• NumPy — scientific computing• Pandas — data analysis
with table-like structures•Matplotlib — 2D plotting
library
![Page 8: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/8.jpg)
Machine learning
• From classical machine learning…• scikit-learn
• … to modern deep learning• TensorFlow• PyTorch• Keras
![Page 9: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/9.jpg)
Machine learning applications in Python
StarGAN
OpenAI GymWit.AI
Image-to-image translation
![Page 10: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/10.jpg)
Why learn Python?
It is simple, yet powerful
Data science and machine learning
Web development
Tons of libraries and frameworks
Huge job market
Great salaries
![Page 11: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/11.jpg)
Web development with Python
•Great for server-side applications•Web frameworks like Flask, Django, Pyramid…• Focused on rapid development
![Page 12: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/12.jpg)
Popular websites that use Python
![Page 13: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/13.jpg)
Why learn Python?
It is simple, yet powerful
Data science and machine learning
Web development
Tons of libraries and frameworks
Huge job market
Great salaries
![Page 14: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/14.jpg)
Wide range of packages
• Nearly 200,000 projects in the Python Package Index (PyPI)• https://pypi.org/• Install with pip install ProjectName
• We already saw examples for data analysis, machine learning, and web development
• Plus web scraping, GUI, image processing, games, natural language processing…
![Page 15: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/15.jpg)
Why learn Python?
It is simple, yet powerful
Data science and machine learning
Web development
Tons of libraries and frameworks
Huge job market
Great salaries
![Page 16: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/16.jpg)
StackOverflow 2019 survey
• Top language current developers want to learn• Second language current users
want to continue to usehttps://insights.stackoverflow.com/survey/2019
![Page 17: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/17.jpg)
Why learn Python?
It is simple, yet powerful
Data science and machine learning
Web development
Tons of libraries and frameworks
Huge job market
Great salaries
![Page 18: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/18.jpg)
StackOverflow2019 survey
• Languages above the line earn better than average given years of experience• Size of the circles
represents number of users
https://insights.stackoverflow.com/survey/2019
![Page 19: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/19.jpg)
What we will we cover in this course
Python specifics• Basic syntax• Data types, data structures, functions, iterators, generators• Function arguments, file I/O, functional programming, classes
Environment• Pip, Conda environments• Jupyter notebooks, Spyder, PyCharm, pydb
Packages• NumPy, Pandas, Matplotlib — data analysis• scikit-learn, Pytorch — machine learning• Pillow — image processing• NLTK — natural language processing• Flask, Django — web development
![Page 20: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/20.jpg)
Some logistics
• Shared 19X lecture at Towne 100• 21 Jan: Linux command-line• 28 Jan: git & github• 4 Feb: internet protocols (like HTTP, DNS)
![Page 21: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/21.jpg)
Some logistics
• We will use Python 3.7• 3.8 was released as the newest stable release in October 2019• Lab machines have Python 3.6.9
• Your main resource will be Python’s documentationhttps://docs.python.org/3/• No required development environment for the course• For early testing, you may use Jupyter notebooks• For turning in homework, you can use your favorite text editor• We will look into different IDEs later in the course
![Page 22: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/22.jpg)
Some logistics
• The syllabus will be continuously updated at https://www.seas.upenn.edu/~cis192/jorge/• Slides and examples will be available after each class• Homeworks will be uploaded according to the syllabus
• We will be using Piazza for discussions and announcements https://piazza.com/upenn/spring2020/cis192202/home• Please post publicly whenever possible• Please join if you’re not already added
![Page 23: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/23.jpg)
Some logistics
• Grading will be based on 8 homework assignments and a final project• Details on the website
• Be sure to read the collaboration policy• Absolutely no code sharing outside of the team project!
![Page 24: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/24.jpg)
Python
![Page 25: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/25.jpg)
Python (from Wikipedia)
• Interpreted: not compiled• High-level: abstracted away from hardware• General-purpose: widest variety of application domain• Readable: ease of comprehending purpose, control flow, and operation
https://en.wikipedia.org/wiki/Python_(programming_language)
![Page 26: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/26.jpg)
Python (from Wikipedia)
• Dynamically typed: types are assigned at runtime• Garbage-collected: unused objects’ memory is freed
https://en.wikipedia.org/wiki/Python_(programming_language)
![Page 27: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/27.jpg)
Python (from Wikipedia)
• Procedural, object-oriented, and functional• Often used for scripting
https://en.wikipedia.org/wiki/Python_(programming_language)
![Page 28: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/28.jpg)
Indentation
• Whitespace indentation to delimit code blocks• Compare to Java’s use of curly braces
• May be achieved with tabs or spaces• Typically 4 spaces per block
• Must be consistent within a block
![Page 29: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/29.jpg)
More on readability
• Semicolons are optional• Comments start with #• Comment blocks delimited with ’’’ or ”””
![Page 30: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/30.jpg)
Assignments
• Assignment operator: =• Example: x = 2• No previous variable declaration (i.e., no int x)• Assign reference of object int with value 2 to name x• Compare to Java: copy value 2 to storage memory assigned to x upon
declaration • x can be assigned a differently typed object later
• Chained assignment is allowed• Example: a = b = 2• Careful! Chained assignments point to the same object, so mutable variables
will change for all references
![Page 31: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/31.jpg)
Control flow
• if — for conditional execution• Along with else and elif (contraction of else if)
• for — for repeated execution over iterable objects • while — for repeated execution until stopping condition• All these statements must be separated from their corresponding
code block by a colon (:)• break, continue — for disrupting the flow of iterations
![Page 32: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/32.jpg)
Live example
![Page 33: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/33.jpg)
The range() function
• Creates an iterable over a range of integer values• Useful for for loops
• range(stop) — from 0 to stop-1• range(start, stop) — from start to stop-1• range(start, stop, step) — from start to stop-1 on
steps of step
![Page 34: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/34.jpg)
Live example
![Page 35: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/35.jpg)
Expressions
• +, -, * — standard addition, substraction, multiplication• ** — exponentiation• / — floating point division• // — integer division
![Page 36: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/36.jpg)
Expressions
• ==, <, >, <=, >= — compare elements by value• == compares objects by value too (like Java’s equals())• a <= b <= c is equivalent to a <= b and b <= c
• is — compare by reference (identity)• Java’s == equivalent for objects
• and, or, not — Boolean operators• x if cond else y — conditional expressions• Compare to Java’s cond ? x : y
![Page 37: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/37.jpg)
Live example
![Page 38: Penn Engineering | Inventing the Futurecis192/jorge/slides/01_introduction.pdfWit.AI Image-to-image translation. Why learn Python? It is simple, yet powerful Data science and machine](https://reader034.vdocument.in/reader034/viewer/2022051605/6012d7d3ebfb9001976bd654/html5/thumbnails/38.jpg)
Takeaways
• Python is simple and powerful• Available packages for wide array of problems:
data science, machine learning, web, image processing, language processing• Great job market• A few initial details on Python syntax