SlideShare a Scribd company logo
Introduction to Data Science in Python
(Visualization ver.)
廻船孝行 (KAISEN Takayuki)
PyCon mini Hiroshima 2018
Contact: ksn0215@gmail.com
Ver. 3.1
Repository: https://github.com/ksnt/pycon_hiro_2018
Overview
1. Geographic Data Analysis
2. Interactive Graph and Application
3. Discussion
Python 3.6.3
Pip 10.0.1
Development Environment
Ubuntu 17.10
・ Injury due to an accident
Notice
・ Hard to pronounce some
words
・ Appreciate for
your cooperation in advance!
0. WHO ARE YOU?
⚫ Favorite Languages
⚪ Python, R, Scala
⚫ Interests
⚪SNA, CSS, CMC, ABM,
Complex Systems,
Data Science, ...
⚫ Python Conference Attendance
⚪PyCon mini JP (2010?)
⚪PyConJP 2011
⚪Tokyo.Scipy (2011?)
⚫ Love Online Learning
⚫ Oct 2017 - HiroshimaFreeman, L. (2004). The development of social network analysis. A Study in the
Sociology of Science, 1.
1. Social network analysis is motivated by a structural in-
tuition based on ties linking social actors,
2. It is grounded in systematic empirical data,
3. It draws heavily on graphic imagery, and
4. It relies on the use of mathematical and/or computation-
al models.
Takeaways: All I am Talking to You
1. It is incredibly easy to make use of
geographic data with Python
(Folium)
2. It is incredibly easy to develop data
driven web application with Python
(Plotly and Dash)
1. Geographic Data Analysis
2. Interactive Graph and Application
3. Discussion
How to use geographic data
GIS = Geographic Information System
“A geographic information system (GIS) is a system designed to capture,
store, manipulate, analyze, manage, and present spatial or geographic
data. “ Wikipedia
YOU DON’T HAVE TO USE GIS!
Reference: “Python Geospatial Development – Third Edition” Chapter2
How to make use of Geographic
data in Python
・ArcGIS, QGIS (PyQGIS)
・Geopandas
・Folium (Leaflet)
・Geopy
・And so forth…
(reference) https://qiita.com/aimof/items/b4e4551d27abaf5bb258
⚪ Do not need knowledge on GIS
⚪ Can easily create Web map
How to install folium
$ pip install folium
$ conda install -c conda-forge folium
or
Data & Visualization(1)
https://nbviewer.jupyter.org/github/ksnt/Predictor-of-blights-in-
Detroit/blob/master/Final_Report_1.1.ipynb
HERE!
Data & Visualization(2)
df = pd.Dataframe()
df = df.attend(crime_data[‘LAT’])
df = df.attend(crime_data[‘LON’])
df = df.T
df = df.reset_index(drop=True)
df[‘LAT’] = round(df[‘LAT’],3)
df[‘LON’] = round(df[‘LON’],3)
df.head()
Data & Visualization(3)
from folium.plugins import HeatMap
from IPython.display import HTML
import folium
map_detroit = folium.Map(location=(42.40,-83.01))
data = []
for i in range(len(df)):
data.append((df['LAT'][i],df['LON'][i]))
HeatMap(data,radius=9).add_to(map_detroit)
map_detroit.save('crimes.html')
HTML(r'<iframe width="800" height="500"
frameborder="0" allowfullscreen
src="./crimes.html"></iframe>')
https://nbviewer.jupyter.org/github/ksnt/Predictor-of-blights-in-
Detroit/blob/master/Final_Report_1.1.ipynb
Data & Visualization(4)
How to visualize geographical data with folium
1. Data cleaning
2. Create map
3. Put the data into the map!
(4. Save the map as a HTML file )
(5. Draw the HTML file )
HeatMap(data,radius=9).add_to(map_detroit)
1. Geographic Data Analysis
2. Interactive Graph and Application
3. Discussion
Data Visualization in Python
⚫ seaborn: cool
⚫ bokeh: cool, interactive
⚫ plotly: cool, interactive, reactive
⚫ matplotlib: standard
⚫ PixieDust (IBM?): interactive, …?
>>> plotly.__version__
'2.4.1'
>>> dash.__version__
'0.21.0'
⚫ mpld3: cool, interactive
How to Use Plotly and Dash
$ pip install plotly
$ pip install dash
$ python
>>> import plotly
>>> import dash
Interactive Graph For Scatter Plot
(Optional)
https://nbviewer.jupyter.org/gist/ksnt/340910aae39670202e4f790213e7afdc
Interactive Graph for Bar Plot
import pandas as pd
import plotly
import plotly.graph_objs as go
df2 = pd.read_excel('globalterrorismdb_0616dist.xlsx',header=0)
data = [go.Bar(
x=df2["country_txt"].value_counts()[:20].index,
y=df2["country_txt"].value_counts()[:20]
)]
layout = go.Layout(
title="Top 20 Frequency of Terrorism Incidents 1970 - 2015",
xaxis={"title":"Country"},
yaxis={"title":"Occurence of terrorism"},
)
fig = go.Figure(data=data, layout=layout) # Preparation of plot by Plotly
plotly.offline.iplot(fig, filename='basic-bar') # not online figure
You have to prepare for this data!
https://nbviewer.jupyter.org/gist/ksnt/eb8ac99dd69ecc5dc5774bf673977ceb
Interactive Graph for Time Series Plot
layout = plotly.graph_objs.Layout(
title="Occurence of Terrorism Incidents",
xaxis={"title":"Year"},
yaxis={"title":"Occurence of terrorism"},
)
iraq_incidents = df2[df2["country_txt"] == "Iraq"]
iraq_incidents_count = iraq_incidents['iyear'].value_counts()
iraq_incidents_count = iraq_incidents_count.sort_index()
iraq = go.Scatter(
x=iraq_incidents_count.index,
y=iraq_incidents_count,
name = "Iraq",
line = dict(color="black"),
Opacity = 0.8)
year = [i for i in range(1970,2016)]
data = [iraq,us,pakistan,india,afghanistan,colombia,peru,phil,el,uk,turkey,spain,sri,somalia,nigeria,algeria,
france,yemen,lebanon]
fig = plotly.graph_objs.Figure(data=data, layout=layout)
plotly.offline.iplot(fig, show_link=False,config={"displaylogo":False, "modeBarButtonsToRemove":
["sendDataToCloud"]})
https://nbviewer.jupyter.org/gist/ksnt/eb8ac99dd69ecc5dc5774bf673977ceb
Additional Example – MonteCarlo
Simulation (Optional)
https://nbviewer.jupyter.org/gist/ksnt/101a44cc21b0eb990f96dc1d640dbd42
Plotly Dash
“”” Dash is Shiny for Python “””
― Chris Parmer, Dash: Shiny for Python
https://youtu.be/5BAthiN0htc
“ Dash is a Python framework for building web application”
・ Flask
・ React.js
・ Ideal for building data visualization apps
Monte Carlo Simulator (1)
https://montecarlo-dash-app.herokuapp.com/
Monte Carlo Simulator (2)
Krauth, W. (2006). Statistical mechanics: algorithms and computations (Vol. 13). OUP Oxford.
Covered by points
Num of all points →S(□) = 4
r=1 r=1
Num of point in the circle
→ S(○) = π
Num of all points
Num of point in the circle
S(○)
S(□)
=
4
π
Count up these points!
Points = {x,y}, x,y 〜 U(-1,1)
Useful article about Monte Carlo Simulation in Japanese is:
—モンテカルロ法の前線 サイコロを振って積分する方法 福島 孝治
https://www.smapip.is.tohoku.ac.jp/~smapip/2003/tutorial/presentation/koji-hukushima.pdf
Institution
Monte Carlo Simulator (3)
https://montecarlo-dash-app.herokuapp.com/
Monte Carlo Simulator (4)
https://gist.github.com/ksnt/ccd88b6f63081e6d2d11f0daf6d0bc4e
⚫ Import libraries
⚫ app = dash.Dash()
server=app.server
server.secret_key = os.environ.get('secret_key', 'secret')
⚫ app.layout = html.Div( # WRITE LAYOUT)
⚫ @app.callback( #WRITE OPERATION)
⚫ if __name__ == '__main__':
app.run_server(debug=True)
View
Controller
Python vs R
as Data Visualization Tool
Speed Extensibility Price Packages/ Libraries
(for Data Analysis)
Python ○ ◎ Free ML
R △ △
OOP
(S3,S4,R5(>=2.12))
Free Statistics
Tableau ? △?
For EDA?
¥18000/year
¥51000/year
¥102000/year
¥0/year students
and teachers
?
Kibana, Superset, Redash, Metabase, Splunk, KNIME, Google Charts, etc…
Julia, Matlab, Scilab, Octave, etc...
3 – 2ε. Welcome to Plotly Dash
Document Translation Project!
https://goo.gl/wnjHA6 HERE!
3 – ε. I am looking for new
opportunities!
・ Places: Anywhere
・ Salary & Benefits: Negotiable
・ Feel free to talk to me!
・ Like: International, Diverse, Python,
Data analysis
1. Geographic Data Analysis
2. Interactive Graph and Application
3. Discussion
Discussion

More Related Content

Similar to Pyconmini Hiroshima 2018

Geospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in PythonGeospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in Python
Halfdan Rump
 
Binary Analysis - Luxembourg
Binary Analysis - LuxembourgBinary Analysis - Luxembourg
Binary Analysis - Luxembourg
Abhik Roychoudhury
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
ajay_opjs
 
Python tools to deploy your machine learning models faster
Python tools to deploy your machine learning models fasterPython tools to deploy your machine learning models faster
Python tools to deploy your machine learning models faster
Jeff Hale
 
Using the Kinect for Fun and Profit by Tam Hanna
Using the Kinect for Fun and Profit by Tam HannaUsing the Kinect for Fun and Profit by Tam Hanna
Using the Kinect for Fun and Profit by Tam Hanna
Codemotion
 
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Jung Kim
 
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
An Introduction to Game Programming with Flash: An Introduction to Flash and ...An Introduction to Game Programming with Flash: An Introduction to Flash and ...
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
Krzysztof Opałka
 
Atari Game State Representation using Convolutional Neural Networks
Atari Game State Representation using Convolutional Neural NetworksAtari Game State Representation using Convolutional Neural Networks
Atari Game State Representation using Convolutional Neural Networks
johnstamford
 
carrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-APIcarrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-API
Yoni Davidson
 
Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...
Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...
Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...
Jason Dai
 
Deep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog DetectorDeep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog Detector
Roelof Pieters
 
(120303) #fitalk ip finder and geo ip for fun
(120303) #fitalk   ip finder and geo ip for fun(120303) #fitalk   ip finder and geo ip for fun
(120303) #fitalk ip finder and geo ip for fun
INSIGHT FORENSIC
 
(120303) #fitalk ip finder and geo ip for fun
(120303) #fitalk   ip finder and geo ip for fun(120303) #fitalk   ip finder and geo ip for fun
(120303) #fitalk ip finder and geo ip for fun
INSIGHT FORENSIC
 
Synthetic Data and Graphics Techniques in Robotics
Synthetic Data and Graphics Techniques in RoboticsSynthetic Data and Graphics Techniques in Robotics
Synthetic Data and Graphics Techniques in Robotics
Prabindh Sundareson
 
#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...
#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...
#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...
Paris Open Source Summit
 
Designing Interactive Web Based AR Experiences
Designing Interactive Web Based AR ExperiencesDesigning Interactive Web Based AR Experiences
Designing Interactive Web Based AR Experiences
FITC
 
David Mertz. Type Annotations. PyCon Belarus 2015
David Mertz. Type Annotations. PyCon Belarus 2015David Mertz. Type Annotations. PyCon Belarus 2015
David Mertz. Type Annotations. PyCon Belarus 2015
Alina Dolgikh
 
Three Functional Programming Technologies for Big Data
Three Functional Programming Technologies for Big DataThree Functional Programming Technologies for Big Data
Three Functional Programming Technologies for Big Data
Dynamical Software, Inc.
 
닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기
YoungSu Son
 
Exploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScriptExploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 

Similar to Pyconmini Hiroshima 2018 (20)

Geospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in PythonGeospatial Data Analysis and Visualization in Python
Geospatial Data Analysis and Visualization in Python
 
Binary Analysis - Luxembourg
Binary Analysis - LuxembourgBinary Analysis - Luxembourg
Binary Analysis - Luxembourg
 
Python Pyplot Class XII
Python Pyplot Class XIIPython Pyplot Class XII
Python Pyplot Class XII
 
Python tools to deploy your machine learning models faster
Python tools to deploy your machine learning models fasterPython tools to deploy your machine learning models faster
Python tools to deploy your machine learning models faster
 
Using the Kinect for Fun and Profit by Tam Hanna
Using the Kinect for Fun and Profit by Tam HannaUsing the Kinect for Fun and Profit by Tam Hanna
Using the Kinect for Fun and Profit by Tam Hanna
 
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
 
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
An Introduction to Game Programming with Flash: An Introduction to Flash and ...An Introduction to Game Programming with Flash: An Introduction to Flash and ...
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
 
Atari Game State Representation using Convolutional Neural Networks
Atari Game State Representation using Convolutional Neural NetworksAtari Game State Representation using Convolutional Neural Networks
Atari Game State Representation using Convolutional Neural Networks
 
carrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-APIcarrow - Go bindings to Apache Arrow via C++-API
carrow - Go bindings to Apache Arrow via C++-API
 
Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...
Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...
Automated ML Workflow for Distributed Big Data Using Analytics Zoo (CVPR2020 ...
 
Deep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog DetectorDeep Learning as a Cat/Dog Detector
Deep Learning as a Cat/Dog Detector
 
(120303) #fitalk ip finder and geo ip for fun
(120303) #fitalk   ip finder and geo ip for fun(120303) #fitalk   ip finder and geo ip for fun
(120303) #fitalk ip finder and geo ip for fun
 
(120303) #fitalk ip finder and geo ip for fun
(120303) #fitalk   ip finder and geo ip for fun(120303) #fitalk   ip finder and geo ip for fun
(120303) #fitalk ip finder and geo ip for fun
 
Synthetic Data and Graphics Techniques in Robotics
Synthetic Data and Graphics Techniques in RoboticsSynthetic Data and Graphics Techniques in Robotics
Synthetic Data and Graphics Techniques in Robotics
 
#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...
#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...
#OSSPARIS19 - Computer Vision framework for GeoSpatial Imagery: RoboSat.pink ...
 
Designing Interactive Web Based AR Experiences
Designing Interactive Web Based AR ExperiencesDesigning Interactive Web Based AR Experiences
Designing Interactive Web Based AR Experiences
 
David Mertz. Type Annotations. PyCon Belarus 2015
David Mertz. Type Annotations. PyCon Belarus 2015David Mertz. Type Annotations. PyCon Belarus 2015
David Mertz. Type Annotations. PyCon Belarus 2015
 
Three Functional Programming Technologies for Big Data
Three Functional Programming Technologies for Big DataThree Functional Programming Technologies for Big Data
Three Functional Programming Technologies for Big Data
 
닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기
 
Exploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScriptExploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScript
 

Recently uploaded

一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Aggregage
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
jitskeb
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
AlessioFois2
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
Social Samosa
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
wyddcwye1
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
v7oacc3l
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
Walaa Eldin Moustafa
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 

Recently uploaded (20)

一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data LakeViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
ViewShift: Hassle-free Dynamic Policy Enforcement for Every Data Lake
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 

Pyconmini Hiroshima 2018

  • 1. Introduction to Data Science in Python (Visualization ver.) 廻船孝行 (KAISEN Takayuki) PyCon mini Hiroshima 2018 Contact: ksn0215@gmail.com Ver. 3.1 Repository: https://github.com/ksnt/pycon_hiro_2018
  • 2. Overview 1. Geographic Data Analysis 2. Interactive Graph and Application 3. Discussion Python 3.6.3 Pip 10.0.1 Development Environment Ubuntu 17.10
  • 3. ・ Injury due to an accident Notice ・ Hard to pronounce some words ・ Appreciate for your cooperation in advance!
  • 4. 0. WHO ARE YOU? ⚫ Favorite Languages ⚪ Python, R, Scala ⚫ Interests ⚪SNA, CSS, CMC, ABM, Complex Systems, Data Science, ... ⚫ Python Conference Attendance ⚪PyCon mini JP (2010?) ⚪PyConJP 2011 ⚪Tokyo.Scipy (2011?) ⚫ Love Online Learning ⚫ Oct 2017 - HiroshimaFreeman, L. (2004). The development of social network analysis. A Study in the Sociology of Science, 1. 1. Social network analysis is motivated by a structural in- tuition based on ties linking social actors, 2. It is grounded in systematic empirical data, 3. It draws heavily on graphic imagery, and 4. It relies on the use of mathematical and/or computation- al models.
  • 5. Takeaways: All I am Talking to You 1. It is incredibly easy to make use of geographic data with Python (Folium) 2. It is incredibly easy to develop data driven web application with Python (Plotly and Dash)
  • 6. 1. Geographic Data Analysis 2. Interactive Graph and Application 3. Discussion
  • 7. How to use geographic data GIS = Geographic Information System “A geographic information system (GIS) is a system designed to capture, store, manipulate, analyze, manage, and present spatial or geographic data. “ Wikipedia YOU DON’T HAVE TO USE GIS! Reference: “Python Geospatial Development – Third Edition” Chapter2
  • 8. How to make use of Geographic data in Python ・ArcGIS, QGIS (PyQGIS) ・Geopandas ・Folium (Leaflet) ・Geopy ・And so forth… (reference) https://qiita.com/aimof/items/b4e4551d27abaf5bb258 ⚪ Do not need knowledge on GIS ⚪ Can easily create Web map
  • 9. How to install folium $ pip install folium $ conda install -c conda-forge folium or
  • 11. Data & Visualization(2) df = pd.Dataframe() df = df.attend(crime_data[‘LAT’]) df = df.attend(crime_data[‘LON’]) df = df.T df = df.reset_index(drop=True) df[‘LAT’] = round(df[‘LAT’],3) df[‘LON’] = round(df[‘LON’],3) df.head()
  • 12. Data & Visualization(3) from folium.plugins import HeatMap from IPython.display import HTML import folium map_detroit = folium.Map(location=(42.40,-83.01)) data = [] for i in range(len(df)): data.append((df['LAT'][i],df['LON'][i])) HeatMap(data,radius=9).add_to(map_detroit) map_detroit.save('crimes.html') HTML(r'<iframe width="800" height="500" frameborder="0" allowfullscreen src="./crimes.html"></iframe>') https://nbviewer.jupyter.org/github/ksnt/Predictor-of-blights-in- Detroit/blob/master/Final_Report_1.1.ipynb
  • 13. Data & Visualization(4) How to visualize geographical data with folium 1. Data cleaning 2. Create map 3. Put the data into the map! (4. Save the map as a HTML file ) (5. Draw the HTML file ) HeatMap(data,radius=9).add_to(map_detroit)
  • 14. 1. Geographic Data Analysis 2. Interactive Graph and Application 3. Discussion
  • 15. Data Visualization in Python ⚫ seaborn: cool ⚫ bokeh: cool, interactive ⚫ plotly: cool, interactive, reactive ⚫ matplotlib: standard ⚫ PixieDust (IBM?): interactive, …? >>> plotly.__version__ '2.4.1' >>> dash.__version__ '0.21.0' ⚫ mpld3: cool, interactive
  • 16. How to Use Plotly and Dash $ pip install plotly $ pip install dash $ python >>> import plotly >>> import dash
  • 17. Interactive Graph For Scatter Plot (Optional) https://nbviewer.jupyter.org/gist/ksnt/340910aae39670202e4f790213e7afdc
  • 18. Interactive Graph for Bar Plot import pandas as pd import plotly import plotly.graph_objs as go df2 = pd.read_excel('globalterrorismdb_0616dist.xlsx',header=0) data = [go.Bar( x=df2["country_txt"].value_counts()[:20].index, y=df2["country_txt"].value_counts()[:20] )] layout = go.Layout( title="Top 20 Frequency of Terrorism Incidents 1970 - 2015", xaxis={"title":"Country"}, yaxis={"title":"Occurence of terrorism"}, ) fig = go.Figure(data=data, layout=layout) # Preparation of plot by Plotly plotly.offline.iplot(fig, filename='basic-bar') # not online figure You have to prepare for this data! https://nbviewer.jupyter.org/gist/ksnt/eb8ac99dd69ecc5dc5774bf673977ceb
  • 19. Interactive Graph for Time Series Plot layout = plotly.graph_objs.Layout( title="Occurence of Terrorism Incidents", xaxis={"title":"Year"}, yaxis={"title":"Occurence of terrorism"}, ) iraq_incidents = df2[df2["country_txt"] == "Iraq"] iraq_incidents_count = iraq_incidents['iyear'].value_counts() iraq_incidents_count = iraq_incidents_count.sort_index() iraq = go.Scatter( x=iraq_incidents_count.index, y=iraq_incidents_count, name = "Iraq", line = dict(color="black"), Opacity = 0.8) year = [i for i in range(1970,2016)] data = [iraq,us,pakistan,india,afghanistan,colombia,peru,phil,el,uk,turkey,spain,sri,somalia,nigeria,algeria, france,yemen,lebanon] fig = plotly.graph_objs.Figure(data=data, layout=layout) plotly.offline.iplot(fig, show_link=False,config={"displaylogo":False, "modeBarButtonsToRemove": ["sendDataToCloud"]}) https://nbviewer.jupyter.org/gist/ksnt/eb8ac99dd69ecc5dc5774bf673977ceb
  • 20. Additional Example – MonteCarlo Simulation (Optional) https://nbviewer.jupyter.org/gist/ksnt/101a44cc21b0eb990f96dc1d640dbd42
  • 21. Plotly Dash “”” Dash is Shiny for Python “”” ― Chris Parmer, Dash: Shiny for Python https://youtu.be/5BAthiN0htc “ Dash is a Python framework for building web application” ・ Flask ・ React.js ・ Ideal for building data visualization apps
  • 22. Monte Carlo Simulator (1) https://montecarlo-dash-app.herokuapp.com/
  • 23. Monte Carlo Simulator (2) Krauth, W. (2006). Statistical mechanics: algorithms and computations (Vol. 13). OUP Oxford. Covered by points Num of all points →S(□) = 4 r=1 r=1 Num of point in the circle → S(○) = π Num of all points Num of point in the circle S(○) S(□) = 4 π Count up these points! Points = {x,y}, x,y 〜 U(-1,1) Useful article about Monte Carlo Simulation in Japanese is: —モンテカルロ法の前線 サイコロを振って積分する方法 福島 孝治 https://www.smapip.is.tohoku.ac.jp/~smapip/2003/tutorial/presentation/koji-hukushima.pdf Institution
  • 24. Monte Carlo Simulator (3) https://montecarlo-dash-app.herokuapp.com/
  • 25. Monte Carlo Simulator (4) https://gist.github.com/ksnt/ccd88b6f63081e6d2d11f0daf6d0bc4e ⚫ Import libraries ⚫ app = dash.Dash() server=app.server server.secret_key = os.environ.get('secret_key', 'secret') ⚫ app.layout = html.Div( # WRITE LAYOUT) ⚫ @app.callback( #WRITE OPERATION) ⚫ if __name__ == '__main__': app.run_server(debug=True) View Controller
  • 26. Python vs R as Data Visualization Tool Speed Extensibility Price Packages/ Libraries (for Data Analysis) Python ○ ◎ Free ML R △ △ OOP (S3,S4,R5(>=2.12)) Free Statistics Tableau ? △? For EDA? ¥18000/year ¥51000/year ¥102000/year ¥0/year students and teachers ? Kibana, Superset, Redash, Metabase, Splunk, KNIME, Google Charts, etc… Julia, Matlab, Scilab, Octave, etc...
  • 27. 3 – 2ε. Welcome to Plotly Dash Document Translation Project! https://goo.gl/wnjHA6 HERE!
  • 28. 3 – ε. I am looking for new opportunities! ・ Places: Anywhere ・ Salary & Benefits: Negotiable ・ Feel free to talk to me! ・ Like: International, Diverse, Python, Data analysis
  • 29. 1. Geographic Data Analysis 2. Interactive Graph and Application 3. Discussion

Editor's Notes

  1. 1.RはOOPで書きづらい ※ただし私が知っているのはS3クラスというものを使うやりかたで、S4やR5といった別のものを使えばそこまで書きづらくもないのかもしれない  参考: https://sites.google.com/site/scriptofbioinformatics/r-tong-ji-guan-xi/rnoobujekuto-zhi-xiangnitsuite-r 2. Rでオレオレグラフを作るのがしんどかった経験 ggplot2を拡張するコードを書いたことがあるがしんどすぎてメゲそうになった。実際に作者であるWickham自身もggplot2の作りについて反省している。 参考:http://yutannihilation.github.io/ggplot2-vignette-ja/extending-ggplot2.html  ただ、一方で例えばPythonmatplotlibを拡張しようとしたときに簡単にできるのかという疑問はある。