Why Python in
Scientific
Research?
Erika Fille Legara, Ph.D.
Program Director, M.S. in Data Science
Asian Institute of Management
@eflegara | eflegara.github.io
July 2017January 2012January 2006
~5.5 years
Master of Science in Data Science
Complex Systems
“In general usage, complexity
tends to be used to
characterize something with
many parts in intricate
arrangement.”
EF Legara • @eflegara • Asian Inst. of Management
Complicated vs.
Complex
EF Legara • @eflegara • Asian Inst. of Management
Complicated vs.
Complex
EF Legara • @eflegara • Asian Inst. of Management
Complex Systems in Nature
EF Legara • @eflegara • Asian Inst. of Management
Complex Systems in Society
EF Legara • @eflegara • Asian Inst. of Management
Complex Systems
• LARGE and DIVERSE
INTERACTING parts
• No centralised control
• SELF-ORGANISATION and
EMERGENCE
• EVOLUTION and ADAPTATION
EF Legara • @eflegara • Asian Inst. of Management
Why Study Complex Systems
1. Demographic change
2. Financial and economic stability
3. Social, economic and political inclusion
4. Public health (epidemics)
5. Balance of power and conflict
6. Corruption and crime
7. Collective social behavior
8. Institutional design
9. Sustainable use of resources
10. Reliability of critical infrastructures
Real-World Issues
EF Legara • @eflegara • Asian Inst. of Management
“I think the next
century will be
the century of
Complexity.”
Complexity Science
“The whole is more
than the sum of its
parts.”
EF Legara • @eflegara • Asian Inst. of Management
Game
Theory
Collective
Behavior
Networks
Evolution &
Adaptation
Pattern
Formation
Systems
Theory
Nonlinear
Dynamics
COMPLEX	SYSTEMS
“The whole is more than the
sum of its parts.”
EF Legara • @eflegara • Asian Inst. of Management
Urban
Complexity
Projects
Bus Arrivals
Waiting time ½ x headway2 =
the area of each
triangle
time
headway
headway
EWT
SWT
AWT
An interactive visual, demand modelling, and decision-support tool.!
Bus Arrivals
Waiting time ½ x headway2 =
the area of each
triangle
time
headway
headway
EWT
SWT
AWT
An interactive visual, demand modelling, and decision-support tool.!An interactive visual, demand modelling, and decision-support tool.!
Bus Arrivals
Waiting time ½ x headway2 =
the area of each
triangle
time
headway
headway
EWT
SWT
AWT
Modeling and
Simulations of
the Rapid Transit
System
Reliability
Analysis of Bus
Arrivals
Lightless
intersection
control numerical
simulations
Land-Use &
Transport Modeling
Crowd Modeling
and Simulations
Characterizing
Public Transport
Commuters
Resilience of
Commuter
Encounter
Networks
Aging, Biology &
Computing:
Healthspan
Identification of
Regulators in a
Human Gene
Network
Urban Morphology
Dynamical Model of
Twitter Activity
Profiles
Diffusion &
Cascading Failures
on Multiplex
Networks
Urban
Complexity
Projects
OPEN-MINDED KA BA?
TARA, KAPE TAYO.
BLACK-BOX models
MECHANISM-BASED
models
START STEP DECISION
ACTION
ACTION
END
END
PREDICTIVE ANALYTICS
EF Legara • @eflegara • Asian Inst. of Management
Multilevel Marketing
or Pyramid Scams?
A mechanism-based model to
reconstruct network marketing
EF Legara • @eflegara • Asian Inst. of Management
Agent-Based Modeling + Network Science
Most real-world systems can only be modeled algorithmically.
“Social Network”
EF Legara • @eflegara • Asian Inst. of Management
Agent-based modeling
a class of computational models
for simulating the
actions and interactions of
autonomous agents
EF Legara • @eflegara • Asian Inst. of Management
Agent-based modeling
• Bottom-up approach
• Simulate actions and interactions of
autonomous agents in a synthetic
virtual “world”
• Best for “what-if” scenario modeling
Applications
• Epidemiology and Contagion
• Traffic
• Financial markets
** EF Legara (2014). Complexity in Public Policy: Tools and Applications (Complex Networks and Agent-Based Models: An Overview).
Managing Complexity from a Public Policy Perspective (A Lecture), Civil Service College, Singapore, 15-16 October 2014.
ABM in Public Policy**
Organisation for Economic Co-operation and
Development (OECD)
Global Science Forum
Agent-Based Modeling
EF Legara, KK Lee, GG Hung, and C Monterola, "Mechanism-based model of a mass rapid transit
system: A perspective," Int. J. Mod. Phys. Conf. Ser. 36, 1560011 (2015).
N Othman, EF Legara, V Selvam, and C Monterola, "A Data-Driven Agent-Based Model of
Congestion and Scaling Dynamics of Rapid Transit Systems," J of Computational Science (2015).
Integrated Public Transportation Visualization and
Simulation Platform of Singapore
Predicting the H1N1 Epidemic
The predicted spread of the H1N1 epidemics during 2009, representing the first successful real-time prediction of a
pandemic [13]. The project, relying on data describing the structure and the dynamics of the worldwide transportation
network, foresaw that H1N1 will peak out in October 2009, in contrast with the expected January-February peak of
influenza. This meant that the vaccines timed for November 2009 were too late, eventually having little impact on the
outcome of the epdemic. The success of this project shows the power of network science in facilitating advances in areas
of key importance for humanity.
Video courtesy of Alessandro Vespignani. Network Science by Albert-Laszlo Barabasi.
EF Legara • @eflegara • Asian Inst. of Management
SOCIETY BUSINESS NETWORK
EF Legara • @eflegara • Asian Inst. of Management
Network Science
• Short path length
• High clustering coefficient
Social Network
EF Legara • @eflegara • Asian Inst. of Management
1
2
3
4
5
6 Can you connect
yourself to
Donald Trump?
Short path length
“It’s a small world!”
EF Legara • @eflegara • Asian Inst. of Management
High clustering coefficient
Our “friends” are
likely to also be
“friends” with each
other.
EF Legara • @eflegara • Asian Inst. of Management
EF Legara • @eflegara • Asian Inst. of Management
C++ C++
import networkx as nx
G = nx.watts_strogatz_graph(n, k, p, seed=None)
EF Legara • @eflegara • Asian Inst. of Management
NetworkX
The built-in
libraries!!
EF Legara • @eflegara • Asian Inst. of Management
EF Legara • @eflegara • Asian Inst. of Management
Aric Hagberg Dan Schult Pieter Swart
The
community!!
EF Legara • @eflegara • Asian Inst. of Management
Watts-Strogatz Social Network Model
Unilevel Business Network
Binary Level Business Network
EF Legara • @eflegara • Asian Inst. of Management
EF Legara, C Monterola, DE Juanico, M Litong-Palima, C. Saloma, "Earning potential in
multilevel marketing enterprises," Physica A 387, pp. 4889-4895 (2008).
Contrary to claims of unbridled growth.
analytic
actual
simulated
NumberofAgents
Level
https://tinyurl.com/erika-aim-mlm EF Legara, C Monterola, DE Juanico, M Litong-Palima, C. Saloma, "Earning potential in
multilevel marketing enterprises," Physica A 387, pp. 4889-4895 (2008).
The Unexpected Effectiveness
of Python in Science
by Jake VanderPlas
EF Legara • @eflegara • Asian Inst. of Management
Game
Theory
Collective
Behavior
Networks
Evolution &
Adaptation
Pattern
Formation
Systems
Theory
Nonlinear
Dynamics
COMPLEX	SYSTEMS
“The whole is more than the sum
of its parts.”
EF Legara • @eflegara • Asian Inst. of Management
Graph-tool
PyPI Dependency Networkhttp://erikafille.ph
C++
Python
http://erikafille.ph
EF Legara • @eflegara • Asian Inst. of Management
GBM
DRF
SVM
Train the
ML models
Adult
Child
Senior Citizen
EF Legara and C Monterola,
"Inferring Passenger Types from
Commuter Eigentravel Matrices,"
Transportmetrica B: Transport
Dynamics, Feb 2017. Doi:
10.1080/21680566.2017.1291377
(“travel DNA”)
https://xkcd.com/353/
EF Legara • @eflegara • Asian Inst. of Management
EF Legara • @eflegara • Asian Inst. of Management
C++ python
EF Legara • @eflegara • Asian Inst. of Management
python
IEEE SCALE Challenge. First Prize Winner
Perfect for prototyping.
python
Scalable complex system modeling
for a sustainable city
EF Legara • @eflegara • Asian Inst. of Management
EF Legara • @eflegara • Asian Inst. of Management
Reproducible
Science
http://eflegara.github.io
Why python?
It’s simple and dynamic!
The built-in libraries!
The community!
The reproducibility!
And many more…
EF Legara • @eflegara • Asian Inst. of Management
Why Python in
Scientific
Research?
Erika Fille Legara, Ph.D.
Program Director, M.S. in Data Science
Asian Institute of Management
@eflegara | eflegara.github.io

Why Python in Scientific Research?

  • 1.
    Why Python in Scientific Research? ErikaFille Legara, Ph.D. Program Director, M.S. in Data Science Asian Institute of Management @eflegara | eflegara.github.io
  • 2.
    July 2017January 2012January2006 ~5.5 years Master of Science in Data Science
  • 3.
    Complex Systems “In generalusage, complexity tends to be used to characterize something with many parts in intricate arrangement.” EF Legara • @eflegara • Asian Inst. of Management
  • 4.
    Complicated vs. Complex EF Legara• @eflegara • Asian Inst. of Management
  • 5.
    Complicated vs. Complex EF Legara• @eflegara • Asian Inst. of Management
  • 6.
    Complex Systems inNature EF Legara • @eflegara • Asian Inst. of Management
  • 7.
    Complex Systems inSociety EF Legara • @eflegara • Asian Inst. of Management
  • 8.
    Complex Systems • LARGEand DIVERSE INTERACTING parts • No centralised control • SELF-ORGANISATION and EMERGENCE • EVOLUTION and ADAPTATION EF Legara • @eflegara • Asian Inst. of Management
  • 9.
    Why Study ComplexSystems 1. Demographic change 2. Financial and economic stability 3. Social, economic and political inclusion 4. Public health (epidemics) 5. Balance of power and conflict 6. Corruption and crime 7. Collective social behavior 8. Institutional design 9. Sustainable use of resources 10. Reliability of critical infrastructures Real-World Issues EF Legara • @eflegara • Asian Inst. of Management
  • 10.
    “I think thenext century will be the century of Complexity.”
  • 11.
    Complexity Science “The wholeis more than the sum of its parts.” EF Legara • @eflegara • Asian Inst. of Management
  • 12.
  • 13.
    Urban Complexity Projects Bus Arrivals Waiting time½ x headway2 = the area of each triangle time headway headway EWT SWT AWT An interactive visual, demand modelling, and decision-support tool.!
  • 14.
    Bus Arrivals Waiting time½ x headway2 = the area of each triangle time headway headway EWT SWT AWT An interactive visual, demand modelling, and decision-support tool.!An interactive visual, demand modelling, and decision-support tool.! Bus Arrivals Waiting time ½ x headway2 = the area of each triangle time headway headway EWT SWT AWT Modeling and Simulations of the Rapid Transit System Reliability Analysis of Bus Arrivals Lightless intersection control numerical simulations Land-Use & Transport Modeling Crowd Modeling and Simulations Characterizing Public Transport Commuters Resilience of Commuter Encounter Networks Aging, Biology & Computing: Healthspan Identification of Regulators in a Human Gene Network Urban Morphology Dynamical Model of Twitter Activity Profiles Diffusion & Cascading Failures on Multiplex Networks Urban Complexity Projects
  • 15.
  • 16.
    BLACK-BOX models MECHANISM-BASED models START STEPDECISION ACTION ACTION END END PREDICTIVE ANALYTICS EF Legara • @eflegara • Asian Inst. of Management
  • 17.
    Multilevel Marketing or PyramidScams? A mechanism-based model to reconstruct network marketing EF Legara • @eflegara • Asian Inst. of Management
  • 18.
    Agent-Based Modeling +Network Science Most real-world systems can only be modeled algorithmically. “Social Network” EF Legara • @eflegara • Asian Inst. of Management
  • 19.
    Agent-based modeling a classof computational models for simulating the actions and interactions of autonomous agents EF Legara • @eflegara • Asian Inst. of Management
  • 20.
    Agent-based modeling • Bottom-upapproach • Simulate actions and interactions of autonomous agents in a synthetic virtual “world” • Best for “what-if” scenario modeling Applications • Epidemiology and Contagion • Traffic • Financial markets ** EF Legara (2014). Complexity in Public Policy: Tools and Applications (Complex Networks and Agent-Based Models: An Overview). Managing Complexity from a Public Policy Perspective (A Lecture), Civil Service College, Singapore, 15-16 October 2014. ABM in Public Policy** Organisation for Economic Co-operation and Development (OECD) Global Science Forum
  • 21.
    Agent-Based Modeling EF Legara,KK Lee, GG Hung, and C Monterola, "Mechanism-based model of a mass rapid transit system: A perspective," Int. J. Mod. Phys. Conf. Ser. 36, 1560011 (2015). N Othman, EF Legara, V Selvam, and C Monterola, "A Data-Driven Agent-Based Model of Congestion and Scaling Dynamics of Rapid Transit Systems," J of Computational Science (2015). Integrated Public Transportation Visualization and Simulation Platform of Singapore Predicting the H1N1 Epidemic The predicted spread of the H1N1 epidemics during 2009, representing the first successful real-time prediction of a pandemic [13]. The project, relying on data describing the structure and the dynamics of the worldwide transportation network, foresaw that H1N1 will peak out in October 2009, in contrast with the expected January-February peak of influenza. This meant that the vaccines timed for November 2009 were too late, eventually having little impact on the outcome of the epdemic. The success of this project shows the power of network science in facilitating advances in areas of key importance for humanity. Video courtesy of Alessandro Vespignani. Network Science by Albert-Laszlo Barabasi. EF Legara • @eflegara • Asian Inst. of Management
  • 22.
    SOCIETY BUSINESS NETWORK EFLegara • @eflegara • Asian Inst. of Management
  • 23.
    Network Science • Shortpath length • High clustering coefficient Social Network EF Legara • @eflegara • Asian Inst. of Management
  • 24.
    1 2 3 4 5 6 Can youconnect yourself to Donald Trump? Short path length “It’s a small world!” EF Legara • @eflegara • Asian Inst. of Management
  • 25.
    High clustering coefficient Our“friends” are likely to also be “friends” with each other. EF Legara • @eflegara • Asian Inst. of Management
  • 26.
    EF Legara •@eflegara • Asian Inst. of Management C++ C++
  • 27.
    import networkx asnx G = nx.watts_strogatz_graph(n, k, p, seed=None) EF Legara • @eflegara • Asian Inst. of Management
  • 28.
    NetworkX The built-in libraries!! EF Legara• @eflegara • Asian Inst. of Management
  • 30.
    EF Legara •@eflegara • Asian Inst. of Management
  • 31.
    Aric Hagberg DanSchult Pieter Swart The community!! EF Legara • @eflegara • Asian Inst. of Management
  • 32.
    Watts-Strogatz Social NetworkModel Unilevel Business Network Binary Level Business Network EF Legara • @eflegara • Asian Inst. of Management EF Legara, C Monterola, DE Juanico, M Litong-Palima, C. Saloma, "Earning potential in multilevel marketing enterprises," Physica A 387, pp. 4889-4895 (2008).
  • 33.
    Contrary to claimsof unbridled growth. analytic actual simulated NumberofAgents Level https://tinyurl.com/erika-aim-mlm EF Legara, C Monterola, DE Juanico, M Litong-Palima, C. Saloma, "Earning potential in multilevel marketing enterprises," Physica A 387, pp. 4889-4895 (2008).
  • 34.
    The Unexpected Effectiveness ofPython in Science by Jake VanderPlas EF Legara • @eflegara • Asian Inst. of Management
  • 35.
  • 36.
  • 37.
  • 38.
    EF Legara •@eflegara • Asian Inst. of Management
  • 40.
    GBM DRF SVM Train the ML models Adult Child SeniorCitizen EF Legara and C Monterola, "Inferring Passenger Types from Commuter Eigentravel Matrices," Transportmetrica B: Transport Dynamics, Feb 2017. Doi: 10.1080/21680566.2017.1291377 (“travel DNA”)
  • 41.
    https://xkcd.com/353/ EF Legara •@eflegara • Asian Inst. of Management
  • 42.
    EF Legara •@eflegara • Asian Inst. of Management
  • 43.
    C++ python EF Legara• @eflegara • Asian Inst. of Management
  • 44.
    python IEEE SCALE Challenge.First Prize Winner Perfect for prototyping. python Scalable complex system modeling for a sustainable city EF Legara • @eflegara • Asian Inst. of Management
  • 45.
    EF Legara •@eflegara • Asian Inst. of Management
  • 46.
  • 47.
    Why python? It’s simpleand dynamic! The built-in libraries! The community! The reproducibility! And many more… EF Legara • @eflegara • Asian Inst. of Management
  • 48.
    Why Python in Scientific Research? ErikaFille Legara, Ph.D. Program Director, M.S. in Data Science Asian Institute of Management @eflegara | eflegara.github.io