SlideShare a Scribd company logo
Dr. Miguel Fierro
@miguelgfierro
Best practices in coding for
beginners
2
Pursuing Artificial Intelligence
Language
Speech
Search
Machine
Learning
Knowledge Vision
3
Agenda
The why, the what and the how of Python
Development
strategies
Software development principles
What’s next?
4
Agenda
The why, the what and the how of Python
Development
strategies
Software development principles
What’s next?
Why Python?
Most popular language
According to PYPL, Python
surpassed Java in 2018 as the most
popular programming language.
The language of AI
It has became the language of AI,
machine learning and deep learning.
Most of the top AI libraries use
python.
Easier
As Python typically involves less
code, it also takes less time to
complete a job. This also means
less money.
Dr. Miguel Fierro - @miguelgfierro
6
The final 2.x version 2.7 release came out in
mid-2010
Python 2.7 will only receive necessary security
updates until 2020
Python 3.5 was released in 2015 and Python
3.6 in 2016.
All recent standard library improvements are
available in Python 3.x by default
Python 2.x Python 3.x
Python 3.x is the present and future
of the language
Dr. Miguel Fierro - @miguelgfierro
7
$ source activate my_env
(my_env) $ pip install –r requirements.txt
bash
Python environments
# file: requirements.txt
Django==1.7.10
markdown2==2.3.0
Pillow==4.2.1
numpy>=1.13.3
opencv>=3.3.0
pyodbc>=4.0.21
requests>=2.18.4
beautifulsoup4>=4.6.0
pandas>=0.22.0
scikit-image>=0.13.1
scikit-learn>=0.19.1
scipy>=0.19.0
matplotlib>=1.5.3
file
Python environments encapsulate development
Dr. Miguel Fierro - @miguelgfierro
8
$ conda create –n my_env –f conda.yaml
$ source activate my_env
(my_env) $
bash
Conda environments
# file: conda.yaml
channels:
- conda-forge
- defaults
dependencies:
- python==3.6
- numpy==1.13.3
- flask==1.0.2
- cherrypy==12.0.1
- ipykernel==4.6.1
- pip:
- pandas==0.22.0
- scipy==1.1.0
- scikit-learn==0.19.1
- jupyter==1.0.0
file
Conda environments make development easier
Dr. Miguel Fierro - @miguelgfierro
Typical project structure
9
docs
robotics
tests
third_party
tools
.coveragerc
.gitignore
.travis.yml
LICENSE.md
README.md
setup.py
Example of library: robotics
10
Agenda
The why, the what and the how of Python
Development
strategies
Software development principles
What’s next?
11
Jupyter notebooks
Dr. Miguel Fierro - @miguelgfierro
Test Driven Development
Develop the tests first
1) Add a test
Write a test that defines a function or
improvements of a function.
It makes the developer focus on the
requirements before writing the code, a
subtle but important difference.
2) Run the test to check it fails
Execute all the tests and check whether
they pass or fail. The new test should fail
for the expected reason.
3) Write the code
Write some code that causes the test to
pass. The new code written at this stage is
not perfect and will be improved later.
At this point, the only purpose of the
written code is to pass the test.
5) Refactor code
Clean the code, remove duplication, avoid
magic numbers (constants without a
variable) and apply other software
development techniques.
4) Run the test to check it passes
The new test should pass.
Now the programmer can be confident
that the new code meets the test
requirements.
6) Repeat
For each new functionality of the code,
start by adding a new test
Dr. Miguel Fierro - @miguelgfierro
13
def test_predict_accuracy (self):
acc = predict()
self.assertGreaterEqual(acc, 0)
self.assertLessEqual(acc, 1)
Type of tests
Python def test_predict_accuracy (self):
acc = predict()
self.assertGreaterEqual(acc, 0.65)
def test_predict_accuracy (self):
acc = predict()
self.assertEqual(acc, 0.654345675)
Unit tests Integration tests Utility tests
It tests the correct behavior It tests that whether the result is acceptable It shows an example of the behavior
Dr. Miguel Fierro - @miguelgfierro
14
How to create a library
Dr. Miguel Fierro - @miguelgfierro
15
def sigmoid(x):
"""Sigmoid function. Output between 0-1
Args:
x (np.array): An array.
Returns:
result (np.array): Sigmoid of the array.
Examples:
>>> x = np.array([[1,1,-3],[0.5,-1,1]])
>>> sigmoid(x)
array([[0.73, 0.73, 0.04],
[0.62, 0.26, 0.73]])
"""
return 1. / (1 + np.exp(-x))
Documentation: Python docstrings
Python
Google style Numpy style
def sigmoid(x):
"""Sigmoid function. Output between 0-1
Parameters
-----------
x : np.array
An array.
Returns
-------
result : np.array
Sigmoid of the array.
Examples
--------
>>> x = np.array([[1,1,-3],[0.5,-1,1]])
>>> sigmoid(x)
array([[0.73, 0.73, 0.04],
[0.62, 0.26, 0.73]])
"""
return 1. / (1 + np.exp(-x))
Dr. Miguel Fierro - @miguelgfierro
16
Code style: PEP8
Python's official style guide, for formatting code
correctly to maximize its readability.
Created in 2001 by Guido van Rossum et. al.
!DILEMMA:
How to automatize the code style?
Use auto-format in your favorite IDE
PyCharm
Free and payed
version
Visual Studio
Heavy weight IDE with
many functionalities
VS Code
Ubuntu default
Atom
Results visualization
No matter which IDE you prefer,
it will save you time and make the
development easier.
Dr. Miguel Fierro - @miguelgfierro
18
Agenda
The why, the what and the how of Python
Development
strategies
Software development principles
What’s next?
Software development principles
Single responsibility DRY
(Don’t Repeat
Yourself)
MVP
(Minimum Viable
Product)
Plan for reuse
Key concepts for creating great software
Dr. Miguel Fierro - @miguelgfierro
Modularity
Single responsibility
Each class or module should be responsible for a
single part of the software, in other words: “A
class should have only one reason to change”.
Part of a broader set of principles called SOLID.
A class does only one thing, a function does only one thing
Dr. Miguel Fierro - @miguelgfierro
DRY
If a piece of code can be generalized and reuse, do it!
Extract a new function or a private method.
Reducing complexity
Don’t Repeat Yourself … please
Dr. Miguel Fierro - @miguelgfierro
Fail fast
MVP
The MVP is the minimum product that collects the
maximum amount of validated learning about
customers with the least effort.
Based on the Lean Startup methodology.
Minimum Viable Product
Dr. Miguel Fierro - @miguelgfierro
Generalize your code to be reusable
Generalization
Plan for reuse
Whenever you create a piece of software, design it
in a way so it can be reusable in other projects.
It will save you a lot of time.
Dr. Miguel Fierro - @miguelgfierro
24
Agenda
The why, the what and the how of Python
Development
strategies
Software development principles
What’s next?
25
Create your own codebase
Dr. Miguel Fierro - @miguelgfierro
26
Start contributing to opensource
Dr. Miguel Fierro - @miguelgfierro
Dr. Miguel Fierro
@miguelgfierro
Best practices in coding for
beginners

More Related Content

What's hot

How Netflix uses Python? Edureka
How Netflix uses Python? EdurekaHow Netflix uses Python? Edureka
How Netflix uses Python? Edureka
Edureka!
 
Robot Framework with Python | Edureka
Robot Framework with Python | EdurekaRobot Framework with Python | Edureka
Robot Framework with Python | Edureka
Edureka!
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
Raveendra R
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Edureka!
 
Is your code ready for testing?
Is your code ready for testing?Is your code ready for testing?
Is your code ready for testing?
Ralph Ligtenberg
 
Comment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowlComment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowl
Pharo
 
5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...
5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...
5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...
Edureka!
 
Introduction to python updated
Introduction to python   updatedIntroduction to python   updated
Introduction to python updated
chakrib5
 
Career in python
Career in pythonCareer in python
Career in python
SSDN Technologies
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief exampleJeremy Kendall
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | Edureka
Edureka!
 
Let's Explore C# 6
Let's Explore C# 6Let's Explore C# 6
Let's Explore C# 6
Jaliya Udagedara
 
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTEDPYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
Bijay Acharya
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming Language
IRJET Journal
 
The Python outside of your textbook
The Python outside of your textbookThe Python outside of your textbook
The Python outside of your textbook
Aniket Prabhu
 
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
DicodingEvent
 
Django
Django Django
Python Programming Course
Python Programming CoursePython Programming Course
Python Programming Course
iseestech
 
The Medusa Project
The Medusa ProjectThe Medusa Project
The Medusa Project
Rahul Dé
 

What's hot (20)

How Netflix uses Python? Edureka
How Netflix uses Python? EdurekaHow Netflix uses Python? Edureka
How Netflix uses Python? Edureka
 
Robot Framework with Python | Edureka
Robot Framework with Python | EdurekaRobot Framework with Python | Edureka
Robot Framework with Python | Edureka
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
 
Is your code ready for testing?
Is your code ready for testing?Is your code ready for testing?
Is your code ready for testing?
 
Comment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowlComment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowl
 
5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...
5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...
5 Simple Steps To Install Python On Windows | Install Python 3.7 | Python Tra...
 
Introduction to python updated
Introduction to python   updatedIntroduction to python   updated
Introduction to python updated
 
Career in python
Career in pythonCareer in python
Career in python
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief example
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | Edureka
 
Let's Explore C# 6
Let's Explore C# 6Let's Explore C# 6
Let's Explore C# 6
 
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTEDPYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming Language
 
The Python outside of your textbook
The Python outside of your textbookThe Python outside of your textbook
The Python outside of your textbook
 
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
 
Django
Django Django
Django
 
Python Programming Course
Python Programming CoursePython Programming Course
Python Programming Course
 
The Medusa Project
The Medusa ProjectThe Medusa Project
The Medusa Project
 

Similar to Best practices in coding for beginners

What makes python 3.11 special
What makes python 3.11 special What makes python 3.11 special
What makes python 3.11 special
Moon Technolabs Pvt. Ltd.
 
DIY in 5 Minutes: Testing Django App with Pytest
DIY in 5 Minutes: Testing Django App with Pytest DIY in 5 Minutes: Testing Django App with Pytest
DIY in 5 Minutes: Testing Django App with Pytest
Inexture Solutions
 
Ways To Become A Good Python Developer
Ways To Become A Good Python DeveloperWays To Become A Good Python Developer
Ways To Become A Good Python Developer
CodeMonk
 
python training.docx
python training.docxpython training.docx
python training.docx
AkshitaYadav49
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptx
Kaviya452563
 
Future of Python Certified Professionals in Data Science and Artificial Intel...
Future of Python Certified Professionals in Data Science and Artificial Intel...Future of Python Certified Professionals in Data Science and Artificial Intel...
Future of Python Certified Professionals in Data Science and Artificial Intel...
M M Nair
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
Tharindu Weerasinghe
 
python Certification Training in marthahalli
python Certification Training in marthahallipython Certification Training in marthahalli
python Certification Training in marthahalli
MUDDUKRISHNA14
 
A Comprehensive Guide to App Development with Python - AppsDevPro
A Comprehensive Guide to App Development with Python - AppsDevProA Comprehensive Guide to App Development with Python - AppsDevPro
A Comprehensive Guide to App Development with Python - AppsDevPro
SofiaCarter4
 
Django strategy-test
Django strategy-testDjango strategy-test
Django strategy-testRoyce Haynes
 
Python in Action.pdf
Python in Action.pdfPython in Action.pdf
Python in Action.pdf
AmirKhan811717
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
Rajani S Togarsi
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Elad Elrom
 
sahil mooc ppt (1).ppt
sahil mooc ppt (1).pptsahil mooc ppt (1).ppt
sahil mooc ppt (1).ppt
Sahil564199
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Spotle.ai
 
iOS Development at Scale @Chegg
iOS Development at Scale @CheggiOS Development at Scale @Chegg
iOS Development at Scale @Chegg
GalOrlanczyk
 
Programming tools for developers
Programming tools for developersProgramming tools for developers
Programming tools for developers
BBVA API Market
 
Software Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous InspectionSoftware Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous Inspection
Josh Gough
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
rupeshchanchal
 

Similar to Best practices in coding for beginners (20)

What makes python 3.11 special
What makes python 3.11 special What makes python 3.11 special
What makes python 3.11 special
 
DIY in 5 Minutes: Testing Django App with Pytest
DIY in 5 Minutes: Testing Django App with Pytest DIY in 5 Minutes: Testing Django App with Pytest
DIY in 5 Minutes: Testing Django App with Pytest
 
Ways To Become A Good Python Developer
Ways To Become A Good Python DeveloperWays To Become A Good Python Developer
Ways To Become A Good Python Developer
 
python training.docx
python training.docxpython training.docx
python training.docx
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptx
 
Future of Python Certified Professionals in Data Science and Artificial Intel...
Future of Python Certified Professionals in Data Science and Artificial Intel...Future of Python Certified Professionals in Data Science and Artificial Intel...
Future of Python Certified Professionals in Data Science and Artificial Intel...
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
 
python Certification Training in marthahalli
python Certification Training in marthahallipython Certification Training in marthahalli
python Certification Training in marthahalli
 
Python
Python Python
Python
 
A Comprehensive Guide to App Development with Python - AppsDevPro
A Comprehensive Guide to App Development with Python - AppsDevProA Comprehensive Guide to App Development with Python - AppsDevPro
A Comprehensive Guide to App Development with Python - AppsDevPro
 
Django strategy-test
Django strategy-testDjango strategy-test
Django strategy-test
 
Python in Action.pdf
Python in Action.pdfPython in Action.pdf
Python in Action.pdf
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
 
sahil mooc ppt (1).ppt
sahil mooc ppt (1).pptsahil mooc ppt (1).ppt
sahil mooc ppt (1).ppt
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
iOS Development at Scale @Chegg
iOS Development at Scale @CheggiOS Development at Scale @Chegg
iOS Development at Scale @Chegg
 
Programming tools for developers
Programming tools for developersProgramming tools for developers
Programming tools for developers
 
Software Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous InspectionSoftware Defect Prevention via Continuous Inspection
Software Defect Prevention via Continuous Inspection
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 

More from Miguel González-Fierro

Los retos de la inteligencia artificial en la sociedad actual
Los retos de la inteligencia artificial en la sociedad actualLos retos de la inteligencia artificial en la sociedad actual
Los retos de la inteligencia artificial en la sociedad actual
Miguel González-Fierro
 
Knowledge Graph Recommendation Systems For COVID-19
Knowledge Graph Recommendation Systems For COVID-19Knowledge Graph Recommendation Systems For COVID-19
Knowledge Graph Recommendation Systems For COVID-19
Miguel González-Fierro
 
Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...
Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...
Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...
Miguel González-Fierro
 
Distributed training of Deep Learning Models
Distributed training of Deep Learning ModelsDistributed training of Deep Learning Models
Distributed training of Deep Learning Models
Miguel González-Fierro
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
Miguel González-Fierro
 
Deep Learning for Sales Professionals
Deep Learning for Sales ProfessionalsDeep Learning for Sales Professionals
Deep Learning for Sales Professionals
Miguel González-Fierro
 
Deep Learning for Lung Cancer Detection
Deep Learning for Lung Cancer DetectionDeep Learning for Lung Cancer Detection
Deep Learning for Lung Cancer Detection
Miguel González-Fierro
 
Mastering Computer Vision Problems with State-of-the-art Deep Learning
Mastering Computer Vision Problems with State-of-the-art Deep LearningMastering Computer Vision Problems with State-of-the-art Deep Learning
Mastering Computer Vision Problems with State-of-the-art Deep Learning
Miguel González-Fierro
 
Speeding up machine-learning applications with the LightGBM library
Speeding up machine-learning applications with the LightGBM librarySpeeding up machine-learning applications with the LightGBM library
Speeding up machine-learning applications with the LightGBM library
Miguel González-Fierro
 
Leveraging Data Driven Research Through Microsoft Azure
Leveraging Data Driven Research Through Microsoft AzureLeveraging Data Driven Research Through Microsoft Azure
Leveraging Data Driven Research Through Microsoft Azure
Miguel González-Fierro
 
Empowering every person on the planet to achieve more
Empowering every person on the planet to achieve moreEmpowering every person on the planet to achieve more
Empowering every person on the planet to achieve more
Miguel González-Fierro
 
Deep Learning for NLP
Deep Learning for NLP Deep Learning for NLP
Deep Learning for NLP
Miguel González-Fierro
 

More from Miguel González-Fierro (12)

Los retos de la inteligencia artificial en la sociedad actual
Los retos de la inteligencia artificial en la sociedad actualLos retos de la inteligencia artificial en la sociedad actual
Los retos de la inteligencia artificial en la sociedad actual
 
Knowledge Graph Recommendation Systems For COVID-19
Knowledge Graph Recommendation Systems For COVID-19Knowledge Graph Recommendation Systems For COVID-19
Knowledge Graph Recommendation Systems For COVID-19
 
Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...
Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...
Thesis dissertation: Humanoid Robot Control of Complex Postural Tasks based o...
 
Distributed training of Deep Learning Models
Distributed training of Deep Learning ModelsDistributed training of Deep Learning Models
Distributed training of Deep Learning Models
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
 
Deep Learning for Sales Professionals
Deep Learning for Sales ProfessionalsDeep Learning for Sales Professionals
Deep Learning for Sales Professionals
 
Deep Learning for Lung Cancer Detection
Deep Learning for Lung Cancer DetectionDeep Learning for Lung Cancer Detection
Deep Learning for Lung Cancer Detection
 
Mastering Computer Vision Problems with State-of-the-art Deep Learning
Mastering Computer Vision Problems with State-of-the-art Deep LearningMastering Computer Vision Problems with State-of-the-art Deep Learning
Mastering Computer Vision Problems with State-of-the-art Deep Learning
 
Speeding up machine-learning applications with the LightGBM library
Speeding up machine-learning applications with the LightGBM librarySpeeding up machine-learning applications with the LightGBM library
Speeding up machine-learning applications with the LightGBM library
 
Leveraging Data Driven Research Through Microsoft Azure
Leveraging Data Driven Research Through Microsoft AzureLeveraging Data Driven Research Through Microsoft Azure
Leveraging Data Driven Research Through Microsoft Azure
 
Empowering every person on the planet to achieve more
Empowering every person on the planet to achieve moreEmpowering every person on the planet to achieve more
Empowering every person on the planet to achieve more
 
Deep Learning for NLP
Deep Learning for NLP Deep Learning for NLP
Deep Learning for NLP
 

Recently uploaded

Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
RicletoEspinosa1
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
dxobcob
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 

Recently uploaded (20)

Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 

Best practices in coding for beginners

  • 1. Dr. Miguel Fierro @miguelgfierro Best practices in coding for beginners
  • 3. 3 Agenda The why, the what and the how of Python Development strategies Software development principles What’s next?
  • 4. 4 Agenda The why, the what and the how of Python Development strategies Software development principles What’s next?
  • 5. Why Python? Most popular language According to PYPL, Python surpassed Java in 2018 as the most popular programming language. The language of AI It has became the language of AI, machine learning and deep learning. Most of the top AI libraries use python. Easier As Python typically involves less code, it also takes less time to complete a job. This also means less money. Dr. Miguel Fierro - @miguelgfierro
  • 6. 6 The final 2.x version 2.7 release came out in mid-2010 Python 2.7 will only receive necessary security updates until 2020 Python 3.5 was released in 2015 and Python 3.6 in 2016. All recent standard library improvements are available in Python 3.x by default Python 2.x Python 3.x Python 3.x is the present and future of the language Dr. Miguel Fierro - @miguelgfierro
  • 7. 7 $ source activate my_env (my_env) $ pip install –r requirements.txt bash Python environments # file: requirements.txt Django==1.7.10 markdown2==2.3.0 Pillow==4.2.1 numpy>=1.13.3 opencv>=3.3.0 pyodbc>=4.0.21 requests>=2.18.4 beautifulsoup4>=4.6.0 pandas>=0.22.0 scikit-image>=0.13.1 scikit-learn>=0.19.1 scipy>=0.19.0 matplotlib>=1.5.3 file Python environments encapsulate development Dr. Miguel Fierro - @miguelgfierro
  • 8. 8 $ conda create –n my_env –f conda.yaml $ source activate my_env (my_env) $ bash Conda environments # file: conda.yaml channels: - conda-forge - defaults dependencies: - python==3.6 - numpy==1.13.3 - flask==1.0.2 - cherrypy==12.0.1 - ipykernel==4.6.1 - pip: - pandas==0.22.0 - scipy==1.1.0 - scikit-learn==0.19.1 - jupyter==1.0.0 file Conda environments make development easier Dr. Miguel Fierro - @miguelgfierro
  • 10. 10 Agenda The why, the what and the how of Python Development strategies Software development principles What’s next?
  • 11. 11 Jupyter notebooks Dr. Miguel Fierro - @miguelgfierro
  • 12. Test Driven Development Develop the tests first 1) Add a test Write a test that defines a function or improvements of a function. It makes the developer focus on the requirements before writing the code, a subtle but important difference. 2) Run the test to check it fails Execute all the tests and check whether they pass or fail. The new test should fail for the expected reason. 3) Write the code Write some code that causes the test to pass. The new code written at this stage is not perfect and will be improved later. At this point, the only purpose of the written code is to pass the test. 5) Refactor code Clean the code, remove duplication, avoid magic numbers (constants without a variable) and apply other software development techniques. 4) Run the test to check it passes The new test should pass. Now the programmer can be confident that the new code meets the test requirements. 6) Repeat For each new functionality of the code, start by adding a new test Dr. Miguel Fierro - @miguelgfierro
  • 13. 13 def test_predict_accuracy (self): acc = predict() self.assertGreaterEqual(acc, 0) self.assertLessEqual(acc, 1) Type of tests Python def test_predict_accuracy (self): acc = predict() self.assertGreaterEqual(acc, 0.65) def test_predict_accuracy (self): acc = predict() self.assertEqual(acc, 0.654345675) Unit tests Integration tests Utility tests It tests the correct behavior It tests that whether the result is acceptable It shows an example of the behavior Dr. Miguel Fierro - @miguelgfierro
  • 14. 14 How to create a library Dr. Miguel Fierro - @miguelgfierro
  • 15. 15 def sigmoid(x): """Sigmoid function. Output between 0-1 Args: x (np.array): An array. Returns: result (np.array): Sigmoid of the array. Examples: >>> x = np.array([[1,1,-3],[0.5,-1,1]]) >>> sigmoid(x) array([[0.73, 0.73, 0.04], [0.62, 0.26, 0.73]]) """ return 1. / (1 + np.exp(-x)) Documentation: Python docstrings Python Google style Numpy style def sigmoid(x): """Sigmoid function. Output between 0-1 Parameters ----------- x : np.array An array. Returns ------- result : np.array Sigmoid of the array. Examples -------- >>> x = np.array([[1,1,-3],[0.5,-1,1]]) >>> sigmoid(x) array([[0.73, 0.73, 0.04], [0.62, 0.26, 0.73]]) """ return 1. / (1 + np.exp(-x)) Dr. Miguel Fierro - @miguelgfierro
  • 16. 16 Code style: PEP8 Python's official style guide, for formatting code correctly to maximize its readability. Created in 2001 by Guido van Rossum et. al. !DILEMMA: How to automatize the code style? Use auto-format in your favorite IDE
  • 17. PyCharm Free and payed version Visual Studio Heavy weight IDE with many functionalities VS Code Ubuntu default Atom Results visualization No matter which IDE you prefer, it will save you time and make the development easier. Dr. Miguel Fierro - @miguelgfierro
  • 18. 18 Agenda The why, the what and the how of Python Development strategies Software development principles What’s next?
  • 19. Software development principles Single responsibility DRY (Don’t Repeat Yourself) MVP (Minimum Viable Product) Plan for reuse Key concepts for creating great software Dr. Miguel Fierro - @miguelgfierro
  • 20. Modularity Single responsibility Each class or module should be responsible for a single part of the software, in other words: “A class should have only one reason to change”. Part of a broader set of principles called SOLID. A class does only one thing, a function does only one thing Dr. Miguel Fierro - @miguelgfierro
  • 21. DRY If a piece of code can be generalized and reuse, do it! Extract a new function or a private method. Reducing complexity Don’t Repeat Yourself … please Dr. Miguel Fierro - @miguelgfierro
  • 22. Fail fast MVP The MVP is the minimum product that collects the maximum amount of validated learning about customers with the least effort. Based on the Lean Startup methodology. Minimum Viable Product Dr. Miguel Fierro - @miguelgfierro
  • 23. Generalize your code to be reusable Generalization Plan for reuse Whenever you create a piece of software, design it in a way so it can be reusable in other projects. It will save you a lot of time. Dr. Miguel Fierro - @miguelgfierro
  • 24. 24 Agenda The why, the what and the how of Python Development strategies Software development principles What’s next?
  • 25. 25 Create your own codebase Dr. Miguel Fierro - @miguelgfierro
  • 26. 26 Start contributing to opensource Dr. Miguel Fierro - @miguelgfierro
  • 27. Dr. Miguel Fierro @miguelgfierro Best practices in coding for beginners