Melissa Weber Mendonça
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: Ecossistema Científico tags: talk description: View the slide with "Slide Mode". slideOptions: transition: fade theme: sky --- <style> body { background: #ffffff; background-color: #ffffff; } .reveal .slides { font-size: 36px; font-family: Palatino; } .reveal .slides h2 { font-family: Palatino; letter-spacing: 0.005em; } .reveal .slides h3 { font-family: Palatino; letter-spacing: 0.005em; } .reveal pre { display: block; width: 100%; } .reveal pre code { max-height: 500px; } </style> ## O Ecossistema Científico no Python ```python import numpy as np import scipy as sp import matplotlib as mpl ``` <img src="https://numpy.org/images/logo.svg" style="background:none; border:none; box-shadow:none; height:70px"> <img src="https://scipy.org/images/logo.svg" style="background:none; border:none; box-shadow:none; height:60px"> <img src="https://matplotlib.org/_static/images/documentation.png" style="background:none; border:none; box-shadow:none; height:60px"> <!-- Put the link to this slide here so people can follow --> slides: `https://hackmd.io/@melissawm/Hyqq6d4N8` --- <!-- 1 --> ### Por que estou falando disso? <img src="https://i.imgur.com/zYIGhhk.png" style="background:none; border:none; box-shadow:none;"> --- <!-- 1 --> ### Por que estou falando disso? <img src="https://i.imgur.com/evAXn00.png" style="background:none; border:none; box-shadow:none;"> --- <!-- 2 --> ### Computação Científica <img src="https://i.imgur.com/EI37j4k.png" style="background:none; border:none; box-shadow:none;"> --- <!-- 3 --> ### Histórico - BLAS (1979) - especificação de rotinas de baixo nível para operações comuns de álgebra linear - LAPACK - MATLAB - Python - Numeric/Numarray - NumPy (2005) --- <!-- 4 --> ### NumPy: a base da computação científica no Python - objeto `ndarray` (array homogêneo n-dimensional) - capacidade de **broadcasting** - funções matemáticas padrão com capacidade de vetorização - ferramentas para a integração de código C/C++ e Fortran - álgebra linear, transformadas de Fourier, gerador de números aleatórios --- <!-- .slide: style="font-size: 20px;" --> <img src="https://media.springernature.com/full/springer-static/image/art%3A10.1038%2Fs41586-020-2649-2/MediaObjects/41586_2020_2649_Fig2_HTML.png" style="background:none; border:none; box-shadow:none; height:550px"> *Fonte: Harris et al., "Array Programming with NumPy", Nature volume 585, pages 357–362 (2020)* --- <!-- 5 --> ### Conceitos básicos: Vetorização Vetorização é a capacidade de expressar operações em arrays sem especificar o que acontece com cada elemento individual (em outras palavras: sem usar loops!) - Código vetorizado é mais conciso e legível - O código fica (ligeiramente) mais parecido com a notação matemática - Mais rápido (usa operações otimizadas em C/Fortran) --- <!-- 6 --> ### Vetorização: Exemplo 1 ```ipython In [1]: v = [i for i in range(1000)] In [2]: %timeit w = [i**2 for i in v] 235 µs ± 9.64 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each) In [3]: v_np = np.arange(1000) In [4]: %timeit w_np = v_np**2 1.27 µs ± 39.6 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) ``` --- <!-- 7 --> ### Como isso acontece? As arrays do NumPy são eficientes porque - são compatíveis com as rotinas de álgebra linear escritas em C/C++ ou Fortran - são *views* de objetos alocados por C/C++, Fortran e Cython - as operações vetorizadas em geral evitam copiar arrays desnecessariamente --- <!-- .slide: style="font-size: 20px;" --> <img src="https://media.springernature.com/full/springer-static/image/art%3A10.1038%2Fs41586-020-2649-2/MediaObjects/41586_2020_2649_Fig1_HTML.png" style="background:none; border:none; box-shadow:none; height:400px; width:800px"> *Fonte: Harris et al., "Array Programming with NumPy", Nature volume 585, pages 357–362 (2020)* --- <!-- 8 --> ### Vetorização: Exemplo 2 ```ipython In [1]: import numpy as np In [2]: v = np.array([1, 2, 3, 4]) In [3]: u = np.array([2, 4, 6, 9]) In [4]: u+v Out[4]: array([ 3, 6, 9, 13]) In [5]: np.dot(u, v) Out[5]: 64 In [6]: u.dtype, type(u) Out[6]: (dtype('int64'), numpy.ndarray) ``` --- <!-- 9 --> ### Vetorização: Exemplo 3 ```ipython In [1]: A = np.array([[1, 2, 3], ...: [4, 5, 6], ...: [7, 8, 9]]) In [2]: A.T Out[2]: array([[1, 4, 7], [2, 5, 8], [3, 6, 9]]) In [3]: A.shape, u.shape Out[3]: ((3, 3), (4,)) In [4]: A.ndim Out[4]: 2 In [5]: u.ndim Out[5]: 1 ``` --- <!-- 10 --> ### (O que são essas dimensões?) <img src="https://fgnt.github.io/python_crashkurs_doc/_images/numpy_array_t.png" style="background:none; border:none; box-shadow:none;" width=600px> <span style="font-size:20px">https://www.oreilly.com/library/view/elegant-scipy/9781491922927/ch01.html</span> --- <!-- 11 --> ### Vetorização: Exemplo 4 ```ipython In [6]: A[0, :] Out[6]: array([1, 2, 3]) In [7]: A.sum() Out[7]: 45 In [8]: A.sum(axis=0) Out[8]: array([12, 15, 18]) In [9]: A.sum(axis=1) Out[9]: array([ 6, 15, 24]) ``` --- <!-- 12 --> ### Vetorização: Exemplo 5 ```ipython In [1]: x = np.arange(-np.pi, np.pi, np.pi/8) In [2]: x Out[2]: array([-3.14159265, -2.74889357, -2.35619449, -1.96349541, -1.57079633, -1.17809725, -0.78539816, -0.39269908, 0. , 0.39269908, 0.78539816, 1.17809725, 1.57079633, 1.96349541, 2.35619449, 2.74889357]) In [3]: np.sin(x) Out[3]: array([-1.22464680e-16, -3.82683432e-01, -7.07106781e-01, -9.23879533e-01, -1.00000000e+00, -9.23879533e-01, -7.07106781e-01, -3.82683432e-01, 0.00000000e+00, 3.82683432e-01, 7.07106781e-01, 9.23879533e-01, 1.00000000e+00, 9.23879533e-01, 7.07106781e-01, 3.82683432e-01]) ``` --- <!-- 13 --> ### Broadcasting Permite fazer operações vetoriais de maneira generalizada. ```ipython In [1]: x = np.array([1, 2, 3]) In [2]: x + 5 Out[2]: array([6, 7, 8]) ``` --- <!-- 14 --> ### Broadcasting ```ipython In [1]: A Out[1]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) In [2]: x Out[2]: array([1, 2, 3]) In [3]: A+x Out[3]: array([[ 2, 4, 6], [ 5, 7, 9], [ 8, 10, 12]]) ``` --- <!-- 15 --> ### Submódulos - `numpy.random` - `numpy.fft` - `numpy.ma` - `numpy.linalg` - `numpy.f2py` --- <!-- .slide: style="font-size: 32px;" --> <!-- 16 --> ### SciPy A SciPy é um conjunto de bibliotecas para computação científica, incluindo: - integração numérica - interpolação - processamento de sinais - álgebra linear - estatística - otimização matemática - tratamento de matrizes esparsas Sua base é a NumPy. --- <!-- 17 --> ### Exemplo: Minimização de funções ```ipython In [1]: from scipy.optimize import fmin In [2]: func = lambda x : x**2 In [3]: fmin(func, -1) Optimization terminated successfully. Current function value: 0.000000 Iterations: 17 Function evaluations: 34 Out[3]: array([8.8817842e-16]) ``` --- <!-- 18 --> ### Matplotlib: figurinhas maneiras - Criada por John Hunter (2003) para ser similar ao MATLAB; - Hoje, possui sua própria API orientada a objetos. --- <!-- 19 --> ### Exemplo 2D ```ipython In [1]: import matplotlib.pyplot as plt In [2]: import numpy as np In [3]: t = np.arange(-5, 5, 0.1) In [4]: plt.plot(t, t**2) Out[4]: [<matplotlib.lines.Line2D at 0x7fe369b7cd90>] In [5]: plt.show() ``` --- <!-- .slide: style="font-size: 30px;" --> <!-- 20 --> ### Exemplo 3D ```ipython from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.4) cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) ax.set_xlim(-40, 40) ax.set_ylim(-40, 40) ax.set_zlim(-100, 100) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') plt.show() ``` --- <!-- 21 --> ### Como juntar os três? <img src="https://pics.me.me/lee-lee-dibango-pmishraworld-math-problem-2-2-me-import-numpy-35881429.png" style="background:none; border:none; box-shadow:none;"> --- <!-- .slide: style="font-size: 30px;" --> <!-- 22 --> ### Exemplo: NumPy+SciPy+Matplotlib ```ipython import numpy as np from scipy.interpolate import interp1d import matplotlib.pyplot as plt # Criação de dados x = np.arange(10) y = x + 5*np.random.rand(10) - 6*np.random.rand(10) # Regressão Linear (a_linear, b_linear) = np.polyfit(x, y, 1) # Ajuste quadrático (a_quad, b_quad, c_quad) = np.polyfit(x, y, 2) # Interpolação f = interp1d(x, y) # Gráfico t = np.linspace(0, 9, 50) plt.title('Exemplo: ajuste de curvas') plt.plot(x, y, 'r*') plt.plot(t, a_linear*t+b_linear,'g') plt.plot(t, a_quad*t**2+b_quad*t+c_quad, 'm') plt.plot(t, f(t), 'b') plt.legend(['linear', 'quadrático', 'interpolação']) plt.show(); ``` --- <!-- 28 --> ### Outras ferramentas - Pandas - SymPy - scikit-learn, scikit-image - Dask, PyTorch, TensorFlow - Julia --- <!-- 26 --> ### Comunidades: usuários e desenvolvedores ![](https://i.imgur.com/dxyXQFn.jpg) *Python Brasil 2019* --- <!-- 27 --> ### Open Source, Software Livre: Ferramentas Todo software livre é *open source* (código aberto) mas nem todo código aberto é software livre! - Formatos abertos - Open Science - Direitos Digitais **Quem pode contribuir?** ![](https://i.imgur.com/kFjkkLn.png) --- ### Linguagens e habilidades | github.com/numpy/numpy | github.com/scipy/scipy | --------|--------------------------------------- | ![](https://i.imgur.com/z6zsl4Q.png) | ![](https://i.imgur.com/HJWrdZr.png) | - Documentação/Escrita técnica - Desenvolvimento Web - Design/UX - Comunicação - Gerenciamento de projetos --- <!-- 29 --> ### Finalizando... ![](https://i.imgur.com/MBQqSmT.jpg) --- <!-- 25/25 --> ### Obrigada! :heart: ## `@melissawm`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully