SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
The Joy of SciPy

            Part I, Dinu Gherman
Part II, Dave Kammeyer (not included here)

          Python Users Berlin
          Meet-up, 2013-02-14
About…
Science…
                       Visualisation
           Analytics
                            Numbers
    Data
                 Math
   Big Data               Algorithms

       Machine Learning

                               … and Python
Science, a Reminder
             Domains
  Math                               Education

                     Visualisation
Data
         Models                  Publication

 Theory
                  Experiments
From Scientific
 Python “Components”…
Nat. Language Toolkit                Matplotlib
Mol. Modelling Toolkit      SymPy    Chaco         PIL
BioPython.org               NumPy    Veusz         OpenCV
PsychoPy.org                Blaze    …             Scikit-image
AstroPython.org
                                    Scikit-learn
      Stackless          Pandas     …
      PyPy               PyTables
      Cython             Disco                Sphinx
      Numba                                   ReST (sample)
      Theano                ………
… to Integrated
Scientific Environments
Legacy:       Py-Distributions:   Py-Environments:
Mathematica   ScientificPython     IPython.org
Matlab        Enthought, EPD      SciPy.org
Maple         Anaconda            Sagemath.org
Magma         Python(x, y)        Wakari.io
                                  Mathics.org
                                  Orange
IPython Shell
• Extended Inter-
  active Python shell
                        • Extensions
                        • Help
• Tab completion
                        • History
• Multi-line editing
                        • Debugger
• Shell access
                        • Bookmarks
• Magic functions
                        • DEMO…
IPython Notebook
• IPython shell in the browser
• Markdown text + executable Python code
• JSON container, including output
• Literate Programming – finally
• Great tutorial experience
• Easy to share running code – w/o hassle
IPython Notebook
         Demo

• Tour of the IPython notebook (built-in)
• Installing a custom extension
• Combined later with Matplotlib demo
IPython Extension Demo
 • Show object graphs
 • Reuse a previously written package
 • Run interactively in the notebook
 • Notebook:
   http://nbviewer.ipython.org/4770302/
 • Code:
   https://gist.github.com/deeplook/4731035
Matplotlib
• Scientific plots
• 2D, 3D, interactive
• Smart axes, grids
• Beautiful math (TeX)
• Widgets, annotations, …
• http://matplotlib.org/gallery.html
Matplotlib Demo
• Simple plots
• Bézier path editor
• Magic cube
Conferences
• http://conference.scipy.org
• https://www.euroscipy.org
• http://pydata.org
                            †
Videos (e.g. by John Hunter , Fernando Pérez et al.):
http://pyvideo.org/category/17/pycon-us-2012
Selected Books
What to take away
• Use available Python tools for your
  scientific domain (trivia)!
• Use IPython shell & notebook, Matplotlib
  – far too powerful to leave to scientists! ;-)
• Have fun with science
  – seriously!


  http://io9.com/5973726/15+year-old-whiz-kid-has-
  research-on-dwarf-galaxies-published-in-nature
Questions?
 Exercise?
Exercise
Run the algorithm below using CPython, Cython, PyPy and Numba and
compare their performance. This is implementing a spigot algorithm
by A. Sale, D. Saada, S. Rabinowitz, as mentioned on
http://mail.python.org/pipermail/edu-sig/2012-December/010721.html.
Code: https://gist.github.com/deeplook/4947835.

def pi_digits(n):
    "Generate n digits of Pi."
    k, a, b, a1, b1 = 2, 4, 1, 12, 4
    while n > 0:
        p, q, k = k * k, 2 * k + 1, k + 1
        a, b, a1, b1 = a1, b1, p * a + q * a1, p * b + q * b1
        d, d1 = a / b, a1 / b1
        while d == d1 and n > 0:
            yield int(d)
            n -= 1
            a, a1 = 10 * (a % b), 10 * (a1 % b1)
            d, d1 = a / b, a1 / b1

>>> list(pi_digits(20))
[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4]

Más contenido relacionado

La actualidad más candente

Pycon2013 : Application of Python in Robotics
Pycon2013  : Application of Python in RoboticsPycon2013  : Application of Python in Robotics
Pycon2013 : Application of Python in RoboticsLentin Joseph
 
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Edureka!
 
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...Edureka!
 
Transfer learning, active learning using tensorflow object detection api
Transfer learning, active learning  using tensorflow object detection apiTransfer learning, active learning  using tensorflow object detection api
Transfer learning, active learning using tensorflow object detection api설기 김
 
Pytorch for tf_developers
Pytorch for tf_developersPytorch for tf_developers
Pytorch for tf_developersAbdul Muneer
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Wen-Wei Liao
 
PyTorch Tutorial for NTU Machine Learing Course 2017
PyTorch Tutorial for NTU Machine Learing Course 2017PyTorch Tutorial for NTU Machine Learing Course 2017
PyTorch Tutorial for NTU Machine Learing Course 2017Yu-Hsun (lymanblue) Lin
 
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from..."PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...Edge AI and Vision Alliance
 
Tensorflow for Beginners
Tensorflow for BeginnersTensorflow for Beginners
Tensorflow for BeginnersSam Dias
 
Tensorflow windows installation
Tensorflow windows installationTensorflow windows installation
Tensorflow windows installationmarwa Ayad Mohamed
 
Introduction to PyTorch
Introduction to PyTorchIntroduction to PyTorch
Introduction to PyTorchJun Young Park
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to TensorflowTzar Umang
 
On the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of PythonOn the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of PythonTakeshi Akutsu
 
On the necessity and inapplicability of python
On the necessity and inapplicability of pythonOn the necessity and inapplicability of python
On the necessity and inapplicability of pythonYung-Yu Chen
 
Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Databricks
 
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICA
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICANATURAL OBJECT ORIENTED PROGRAMMING USING ELICA
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICANIKHIL NAWATHE
 

La actualidad más candente (20)

Pycon2013 : Application of Python in Robotics
Pycon2013  : Application of Python in RoboticsPycon2013  : Application of Python in Robotics
Pycon2013 : Application of Python in Robotics
 
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
 
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...
 
TensorFlow Object Detection API
TensorFlow Object Detection APITensorFlow Object Detection API
TensorFlow Object Detection API
 
Transfer learning, active learning using tensorflow object detection api
Transfer learning, active learning  using tensorflow object detection apiTransfer learning, active learning  using tensorflow object detection api
Transfer learning, active learning using tensorflow object detection api
 
Pytorch for tf_developers
Pytorch for tf_developersPytorch for tf_developers
Pytorch for tf_developers
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012
 
PyTorch Tutorial for NTU Machine Learing Course 2017
PyTorch Tutorial for NTU Machine Learing Course 2017PyTorch Tutorial for NTU Machine Learing Course 2017
PyTorch Tutorial for NTU Machine Learing Course 2017
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from..."PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
 
Tensorflow for Beginners
Tensorflow for BeginnersTensorflow for Beginners
Tensorflow for Beginners
 
Tensorflow windows installation
Tensorflow windows installationTensorflow windows installation
Tensorflow windows installation
 
Introduction to PyTorch
Introduction to PyTorchIntroduction to PyTorch
Introduction to PyTorch
 
NUMPY
NUMPY NUMPY
NUMPY
 
Introduction to Tensorflow
Introduction to TensorflowIntroduction to Tensorflow
Introduction to Tensorflow
 
On the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of PythonOn the Necessity and Inapplicability of Python
On the Necessity and Inapplicability of Python
 
On the necessity and inapplicability of python
On the necessity and inapplicability of pythonOn the necessity and inapplicability of python
On the necessity and inapplicability of python
 
Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0
 
Sci py india_conference_2019
Sci py india_conference_2019Sci py india_conference_2019
Sci py india_conference_2019
 
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICA
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICANATURAL OBJECT ORIENTED PROGRAMMING USING ELICA
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICA
 

Destacado

Twittori - Twittwoch Berlin
Twittori - Twittwoch BerlinTwittori - Twittwoch Berlin
Twittori - Twittwoch BerlinDinu Gherman
 
Hipster PDA, A4, Filofax Pocket
Hipster PDA, A4, Filofax PocketHipster PDA, A4, Filofax Pocket
Hipster PDA, A4, Filofax PocketDinu Gherman
 
Plastic kills - Labels
Plastic kills - LabelsPlastic kills - Labels
Plastic kills - LabelsDinu Gherman
 
Plastik tötet - Aufkleber
Plastik tötet - AufkleberPlastik tötet - Aufkleber
Plastik tötet - AufkleberDinu Gherman
 
Sociocracy 3.0 a brief introduction (presentation) (v2016-01-29)
Sociocracy 3.0   a brief introduction (presentation) (v2016-01-29)Sociocracy 3.0   a brief introduction (presentation) (v2016-01-29)
Sociocracy 3.0 a brief introduction (presentation) (v2016-01-29)Bernhard Bockelbrink
 
Writing your bio on Kloodle
Writing your bio on KloodleWriting your bio on Kloodle
Writing your bio on KloodlePhillip Hayes
 

Destacado (7)

Twittori - Twittwoch Berlin
Twittori - Twittwoch BerlinTwittori - Twittwoch Berlin
Twittori - Twittwoch Berlin
 
Hipster PDA, A4, Filofax Pocket
Hipster PDA, A4, Filofax PocketHipster PDA, A4, Filofax Pocket
Hipster PDA, A4, Filofax Pocket
 
Sociocracy
SociocracySociocracy
Sociocracy
 
Plastic kills - Labels
Plastic kills - LabelsPlastic kills - Labels
Plastic kills - Labels
 
Plastik tötet - Aufkleber
Plastik tötet - AufkleberPlastik tötet - Aufkleber
Plastik tötet - Aufkleber
 
Sociocracy 3.0 a brief introduction (presentation) (v2016-01-29)
Sociocracy 3.0   a brief introduction (presentation) (v2016-01-29)Sociocracy 3.0   a brief introduction (presentation) (v2016-01-29)
Sociocracy 3.0 a brief introduction (presentation) (v2016-01-29)
 
Writing your bio on Kloodle
Writing your bio on KloodleWriting your bio on Kloodle
Writing your bio on Kloodle
 

Similar a The Joy of SciPy, Part I

Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientistsaeberspaecher
 
Python on Science ? Yes, We can.
Python on Science ?   Yes, We can.Python on Science ?   Yes, We can.
Python on Science ? Yes, We can.Marcel Caraciolo
 
Python @ PiTech - March 2009
Python @ PiTech - March 2009Python @ PiTech - March 2009
Python @ PiTech - March 2009tudorprodan
 
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)PyData
 
Pycon tw 2013
Pycon tw 2013Pycon tw 2013
Pycon tw 2013show you
 
3 python packages
3 python packages3 python packages
3 python packagesFEG
 
APPLICATION OF PYTHON IN GEOSCIENCE
APPLICATION OF  PYTHON IN GEOSCIENCEAPPLICATION OF  PYTHON IN GEOSCIENCE
APPLICATION OF PYTHON IN GEOSCIENCEAhasanHabibSajeeb
 
What is Python? (Silicon Valley CodeCamp 2015)
What is Python? (Silicon Valley CodeCamp 2015)What is Python? (Silicon Valley CodeCamp 2015)
What is Python? (Silicon Valley CodeCamp 2015)wesley chun
 
Python in the Atmospheric sciences
Python in the Atmospheric sciencesPython in the Atmospheric sciences
Python in the Atmospheric sciencesScott Collis
 
Python. Why to learn?
Python. Why to learn?Python. Why to learn?
Python. Why to learn?Oleh Korkh
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysisPramod Toraskar
 
Open source project of the week
Open source project of the weekOpen source project of the week
Open source project of the weekventuresity
 

Similar a The Joy of SciPy, Part I (20)

Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientists
 
Python on Science ? Yes, We can.
Python on Science ?   Yes, We can.Python on Science ?   Yes, We can.
Python on Science ? Yes, We can.
 
Python @ PiTech - March 2009
Python @ PiTech - March 2009Python @ PiTech - March 2009
Python @ PiTech - March 2009
 
Sci computing using python
Sci computing using pythonSci computing using python
Sci computing using python
 
Intro
IntroIntro
Intro
 
what is python ?
what is python ? what is python ?
what is python ?
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
 
Pycon tw 2013
Pycon tw 2013Pycon tw 2013
Pycon tw 2013
 
PyCon Estonia 2019
PyCon Estonia 2019PyCon Estonia 2019
PyCon Estonia 2019
 
3 python packages
3 python packages3 python packages
3 python packages
 
APPLICATION OF PYTHON IN GEOSCIENCE
APPLICATION OF  PYTHON IN GEOSCIENCEAPPLICATION OF  PYTHON IN GEOSCIENCE
APPLICATION OF PYTHON IN GEOSCIENCE
 
What is Python? (Silicon Valley CodeCamp 2015)
What is Python? (Silicon Valley CodeCamp 2015)What is Python? (Silicon Valley CodeCamp 2015)
What is Python? (Silicon Valley CodeCamp 2015)
 
Python in the Atmospheric sciences
Python in the Atmospheric sciencesPython in the Atmospheric sciences
Python in the Atmospheric sciences
 
Doing the Impossible
Doing the ImpossibleDoing the Impossible
Doing the Impossible
 
London level39
London level39London level39
London level39
 
Python. Why to learn?
Python. Why to learn?Python. Why to learn?
Python. Why to learn?
 
Python Científico
Python CientíficoPython Científico
Python Científico
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
 
Open source project of the week
Open source project of the weekOpen source project of the week
Open source project of the week
 

The Joy of SciPy, Part I

  • 1. The Joy of SciPy Part I, Dinu Gherman Part II, Dave Kammeyer (not included here) Python Users Berlin Meet-up, 2013-02-14
  • 2. About… Science… Visualisation Analytics Numbers Data Math Big Data Algorithms Machine Learning … and Python
  • 3. Science, a Reminder Domains Math Education Visualisation Data Models Publication Theory Experiments
  • 4. From Scientific Python “Components”… Nat. Language Toolkit Matplotlib Mol. Modelling Toolkit SymPy Chaco PIL BioPython.org NumPy Veusz OpenCV PsychoPy.org Blaze … Scikit-image AstroPython.org Scikit-learn Stackless Pandas … PyPy PyTables Cython Disco Sphinx Numba ReST (sample) Theano ………
  • 5. … to Integrated Scientific Environments Legacy: Py-Distributions: Py-Environments: Mathematica ScientificPython IPython.org Matlab Enthought, EPD SciPy.org Maple Anaconda Sagemath.org Magma Python(x, y) Wakari.io Mathics.org Orange
  • 6. IPython Shell • Extended Inter- active Python shell • Extensions • Help • Tab completion • History • Multi-line editing • Debugger • Shell access • Bookmarks • Magic functions • DEMO…
  • 7. IPython Notebook • IPython shell in the browser • Markdown text + executable Python code • JSON container, including output • Literate Programming – finally • Great tutorial experience • Easy to share running code – w/o hassle
  • 8. IPython Notebook Demo • Tour of the IPython notebook (built-in) • Installing a custom extension • Combined later with Matplotlib demo
  • 9. IPython Extension Demo • Show object graphs • Reuse a previously written package • Run interactively in the notebook • Notebook: http://nbviewer.ipython.org/4770302/ • Code: https://gist.github.com/deeplook/4731035
  • 10. Matplotlib • Scientific plots • 2D, 3D, interactive • Smart axes, grids • Beautiful math (TeX) • Widgets, annotations, … • http://matplotlib.org/gallery.html
  • 11. Matplotlib Demo • Simple plots • Bézier path editor • Magic cube
  • 12. Conferences • http://conference.scipy.org • https://www.euroscipy.org • http://pydata.org † Videos (e.g. by John Hunter , Fernando Pérez et al.): http://pyvideo.org/category/17/pycon-us-2012
  • 14. What to take away • Use available Python tools for your scientific domain (trivia)! • Use IPython shell & notebook, Matplotlib – far too powerful to leave to scientists! ;-) • Have fun with science – seriously! http://io9.com/5973726/15+year-old-whiz-kid-has- research-on-dwarf-galaxies-published-in-nature
  • 16. Exercise Run the algorithm below using CPython, Cython, PyPy and Numba and compare their performance. This is implementing a spigot algorithm by A. Sale, D. Saada, S. Rabinowitz, as mentioned on http://mail.python.org/pipermail/edu-sig/2012-December/010721.html. Code: https://gist.github.com/deeplook/4947835. def pi_digits(n): "Generate n digits of Pi." k, a, b, a1, b1 = 2, 4, 1, 12, 4 while n > 0: p, q, k = k * k, 2 * k + 1, k + 1 a, b, a1, b1 = a1, b1, p * a + q * a1, p * b + q * b1 d, d1 = a / b, a1 / b1 while d == d1 and n > 0: yield int(d) n -= 1 a, a1 = 10 * (a % b), 10 * (a1 % b1) d, d1 = a / b, a1 / b1 >>> list(pi_digits(20)) [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4]