Download - Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro
![Page 1: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/1.jpg)
Py “Baseball” Data PyCon mini Hirosima 2016
Python
Shinichi Nakagawa(Baseball Analyst&Pythonista)
![Page 2: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/2.jpg)
Starting Member
• Who am I?( )
• PyData
• PyData / #
• Python
• PyData + (FIP/RC27)
•
![Page 3: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/3.jpg)
Who am I?
• Shinichi Nakagawa(@shinyorke)
• Python , Hack ※ Python
• HR .
• Python/Agile/PyData/SABRmetrics( )
•
• ( ) .
![Page 4: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/4.jpg)
• ( ) HR .
• 1 2
.
• (Django) Python .
• https://service.visasq.com
• https://tech.visasq.com
![Page 5: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/5.jpg)
•
•
•
• &
• etc…
• Web Python
![Page 6: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/6.jpg)
•
• IPython + pandas
(Hello World )
•
![Page 7: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/7.jpg)
•
.
.
• Deep Learning ,
.
• (Pandas )
& .
![Page 8: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/8.jpg)
PyData / #
![Page 9: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/9.jpg)
PyData
![Page 10: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/10.jpg)
“”” PyData
Python Python Library
“””
※@iktakahiro http://www.slideshare.net/iktakahiro/pydata-67913897
![Page 11: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/11.jpg)
PyData
• , ,Python
&( ) .
• , or .
• Excel Python, Deep Learning,
etc… PyData
PyData ( )
![Page 12: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/12.jpg)
( )
![Page 13: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/13.jpg)
“””
“”” https://ja.wikipedia.org/wiki/
![Page 14: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/14.jpg)
( )
• ,
• 1970
, &
•
( , )
![Page 15: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/15.jpg)
•
• ( , ,FA)
• ( )
•
• ( , etc…)
• ( , J )
![Page 16: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/16.jpg)
× ( ) ※ × +
![Page 17: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/17.jpg)
× ( ) ※ × +
![Page 18: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/18.jpg)
※
![Page 19: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/19.jpg)
5
![Page 20: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/20.jpg)
• ( - ) = 5 ( )
•
•
•
•
![Page 21: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/21.jpg)
•
.
• ( - ) 5 5
(ry .
• = ( 2 )÷( 2 + 2 )
•
![Page 22: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/22.jpg)
Python×Pandas
![Page 23: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/23.jpg)
Python×pandas
# Python 3 (3.4 ) ( )$ pip install ipython pandas beautifulsoup4 numpy lxml html5lib# ipython ( Jupyter )$ ipython
![Page 24: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/24.jpg)
Python×pandas
# import pandas as pdimport numpy as np
# ( )df = pd.read_html('http://baseball.yahoo.co.jp/npb/standings/')
# df_cl = df[0].drop([0]) #
![Page 25: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/25.jpg)
Python×pandas
# # ( )df_cl.columns = ['rank', 'name', 'games', 'win', 'lose', 'draw', 'pct', 'gb', 're_games', 'r', 'er', 'hr', 'sb', 'ba', 'era']
# df_cl['win'] = df_cl['win'].fillna(0).astype(np.int64) # df_cl['lose'] = df_cl['lose'].fillna(0).astype(np.int64) # df_cl['pct'] = df_cl['pct'].fillna(0).astype(np.float64) # df_cl['r'] = df_cl['r'].fillna(0).astype(np.int64) # df_cl['er'] = df_cl['er'].fillna(0).astype(np.int64) #
![Page 26: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/26.jpg)
Python×pandas
# df_cl['difference'] = df_cl['r'] - df_cl['er']
# df_cl['pythagorean_win_per'] = (df_cl['r'] ** 2) / (df_cl['r'] ** 2 + df_cl['er'] ** 2)
# df_cl['pythagorean_win'] = (df_cl['pythagorean_win_per'] * 143).fillna(0).astype(np.int64)
df_cl['pythagorean_lose'] = 143 - df_cl['pythagorean_win']
# df_cl.sort_values(by='pythagorean_win_per', ascending=False)
![Page 27: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/27.jpg)
https://gist.github.com/Shinichi-Nakagawa/8ff55af83390fcd2e2dd34bcb914868c
![Page 28: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/28.jpg)
( )
![Page 29: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/29.jpg)
×
![Page 30: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/30.jpg)
•
• (+187)
• 5
• /
• DeNA ,
•
• ( )
![Page 31: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/31.jpg)
![Page 32: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/32.jpg)
?
![Page 33: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/33.jpg)
( )
• & (& )
• , , ,
•
![Page 34: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/34.jpg)
×PyData
• FIP
• (RC27)
• scrapy CSV
• CSV pandas, seaborn, jupyter &
( )
![Page 35: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/35.jpg)
FIP(Fielding Independent Pitching)
• , ( )
• , (+ ),
• ( )
• xFIP
FIP .
![Page 36: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/36.jpg)
FIP( TOP 20)
![Page 37: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/37.jpg)
FIP( & )
![Page 38: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/38.jpg)
FIP(50 Histogram)
![Page 39: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/39.jpg)
FIP(50 Histogram)
![Page 40: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/40.jpg)
FIP(50 Histogram)
![Page 41: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/41.jpg)
FIP
•
•
•
• FIP
•
FIP ( )
![Page 42: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/42.jpg)
RC27
• 9 1
?
• VS , ?
• RC(Run Created, ) 1
•
![Page 43: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/43.jpg)
RC27 (350 )
![Page 44: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/44.jpg)
RC27 TOP30(350 )
![Page 45: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/45.jpg)
RC27(Histogram)
![Page 46: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/46.jpg)
RC27(Histogram)
![Page 47: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/47.jpg)
RC27(Histogram)
![Page 48: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/48.jpg)
RC27
• 1-6
• RC27 Top30 6
•
•
•
• ( )
![Page 49: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/49.jpg)
•
6 Top30
• ,
• ,
, FIP ( )
•
![Page 50: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/50.jpg)
[ ]
• ,
FIP, WHIP, K/BB, etc…
• ,
RC27 3 ( 6 )
•
![Page 51: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/51.jpg)
Py "Baseball" Data - Python ※pandas, Re:dash (& )
MonotaRO TechTalk #4
http://www.kokuchpro.com/event/monotarotech4/
![Page 52: Py "Baseball" Data入門 - 広島東洋カープ編 #pyconhiro](https://reader030.vdocuments.mx/reader030/viewer/2022020119/5877901c1a28ab0f778b4fa9/html5/thumbnails/52.jpg)
&
Shinichi Nakagawa(Twitter/Facebook/visasQ:@shinyorke)