Learning Data Science Through the Lens of Sports
Eric A. Eager, Richard A. Erickson

#Football
#Python
#R
#Data_Science
#Sports
#Baseball
📘 معرفی کتاب
اگر با مفهوم Moneyball در بیسبال آشنا باشی، احتمالاً میدونی که ایده اصلیش استفاده از دادهها برای پیدا کردن مزیت رقابتیه. اما این رویکرد مدتهاست که از بیسبال فراتر رفته. در فوتبال آمریکایی هم تیمهای حرفهای، بازیکنان فانتزی فوتبال، هواداران و حتی شرطبندان ورزشی به شکل فزایندهای از دادهها برای تصمیمگیری بهتر استفاده میکنن.
تیمهای حرفهای و دانشگاهی از تحلیل داده برای شناسایی نقاط ضعف و نیازهای تیم و همچنین انتخاب بازیکنان مناسب استفاده میکنن. بازیکنان فانتزی فوتبال و هواداران از دادهها برای شکست دادن دوستانشون در لیگهای فانتزی کمک میگیرن و شرطبندان ورزشی هم تلاش میکنن با استفاده از تحلیل داده از بازارهای شرطبندی جلوتر باشن.
🏈 در این کتاب کمحجم اما کاربردی، اریک ایگر و ریچارد اریکسون یک مقدمه شفاف و عملی برای تحلیل دادههای فوتبال آمریکایی با استفاده از مدلهای آماری در Python و R ارائه میکنن.
فرقی نمیکنه هدفت ورود به اولین موقعیت شغلی تحلیل فوتبال باشه، بخوای در لیگ فانتزی خودت عملکرد بهتری داشته باشی یا صرفاً دنبال یادگیری Python و R از طریق مثالهای جذاب باشی؛ این کتاب نقطه شروع مناسبیه.
🧠 در قالب مطالعات موردی واقعی در Python و R یاد میگیری:
📑 فهرست مطالب
1. تحلیل فوتبال آمریکایی
2. تحلیل اکتشافی دادهها:
3. رگرسیون خطی ساده:
4. رگرسیون چندگانه:
5. مدلهای خطی تعمیمیافته:
6. استفاده از علم داده در شرطبندی ورزشی:
7. وباسکرپینگ:
8. تحلیل مؤلفههای اصلی و خوشهبندی:
9. ابزارهای پیشرفته و گامهای بعدی
پیوست A. مبانی Python و R
پیوست B. آمارهای توصیفی و آمادهسازی داده
پیوست C. مبانی آمادهسازی داده
🎯 این کتاب دو گروه مخاطب اصلی داره.
اولین گروه افرادی هستن که میخوان تحلیل فوتبال رو از طریق انجام تحلیل فوتبال یاد بگیرن.
در طول کتاب مثالها و تمرینهایی ارائه میشن که دقیقاً شبیه مسائلی هستن که یک تحلیلگر فوتبال با اونها روبهرو میشه. نویسندهها فقط نتیجه نهایی رو نشون نمیدن؛ بلکه توضیح میدن هنگام نگاه کردن به دادههای فوتبال چطور فکر میکنن و بعد مرحلهبهمرحله نحوه تحلیل اون دادهها رو نشون میدن.
ممکنه:
📊 گروه دوم افرادی هستن که میخوان وارد دنیای علم داده بشن اما دوست ندارن یادگیری رو با دیتاستهای کلیشهای شروع کنن.
خیلی از دورههای مقدماتی علم داده هنوز از مثالهایی مثل اندازهگیری گلها در دهه ۱۹۳۰ یا جدول بازماندگان کشتی تایتانیک استفاده میکنن. نویسندهها معتقدن یادگیری مفاهیم علم داده روی موضوعی جذاب مثل فوتبال آمریکایی تجربه بسیار لذتبخشتریه.
🧮 فرض کتاب اینه که حداقل ریاضیات دبیرستانی رو گذروندی؛ حتی اگر سالها از آخرین باری که درس ریاضی خوندی گذشته باشه.
ممکنه دانشآموز دبیرستان باشی یا فردی که سی ساله کلاس ریاضی نرفته. در هر صورت مفاهیم موردنیاز در طول مسیر توضیح داده میشن.
🏈 یکی از اهداف اصلی کتاب اینه که نشون بده فوتبال چطور میتونه بستری جذاب برای یادگیری مفاهیم آماری و علم داده باشه.
برای خیلی از هواداران فوتبال، مهارتهایی که در این کتاب یاد میگیرن کاملاً کافی خواهد بود. اما اگر قصد داری به یک تحلیلگر حرفهای فوتبال تبدیل بشی، نویسندهها امیدوارن این کتاب سکوی پرتابی برای ادامه مسیر یادگیریت باشه.
📂 تمام مثالهای کتاب روی دادههای عمومی ساخته شدن. این موضوع دو مزیت مهم داره:
اول اینکه میتونی تمام تحلیلهای کتاب رو خودت بازتولید کنی.
دوم اینکه بعداً میتونی همون تحلیلها رو برای فصلهای جدید بهروزرسانی کنی.
برای مثال، دادههای کتاب فقط تا پایان فصل 2022 رو پوشش میدن چون هنگام نگارش کتاب آخرین فصل کامل NFL همین فصل بوده. اما ابزارهایی که یاد میگیری بهت اجازه میدن بهسادگی فصلهای بعدی رو هم به تحلیلها اضافه کنی.
🛠️ نویسندهها تمام مراحل آمادهسازی داده رو هم بهصورت کامل نشون میدن تا ببینی داده خام چطور به داده قابلتحلیل تبدیل میشه.
این بخشها گاهی ممکنه کمی خستهکننده به نظر برسن، اما در عمل یکی از مهمترین مهارتهایی هستن که یاد میگیری. وقتی کار با داده رو بلد باشی، برای دسترسی به داده تمیز و آماده وابسته به دیگران نخواهی بود.
🚫 اگر تجربه قابلتوجهی در آمار، Python یا R داری، احتمالاً این کتاب چیز جدید زیادی بهت یاد نمیده.
البته هنوز ممکنه برات جالب باشه که ببینی تحلیلگران فوتبال با چه نوع مسائل مقدماتی کارشون رو شروع میکنن، اما از نظر آموزشی احتمالاً بهتره سراغ منابع پیشرفتهتر بری.
برای مثال:
همچنین میتونی مستقیماً وارد موضوعات پیشرفتهتری بشی که این کتاب فقط بهصورت مقدماتی بهشون اشاره میکنه:
⚙️ یکی از تصمیمهای آگاهانه نویسندهها این بوده که سادگی رو به پیچیدگی ترجیح بدن.
به همین دلیل:
هدف اینه که هرچه سریعتر بتونی با دادههای واقعی کار کنی و وارد فضای تحلیل بشی.
💡 نویسندهها در این بخش به نقلقول معروفی که معمولاً به آنتوان دو سنتاگزوپری نسبت داده میشه اشاره میکنن:
اگر میخواهی کشتی بسازی، آدمها را برای بریدن چوب سازماندهی نکن. در عوض اشتیاق به دریای بیکران را در آنها ایجاد کن.
🌊 فلسفه این کتاب هم دقیقاً همینه.
بهجای اینکه از همون ابتدا درگیر جزئیات فنی سنگین بشی، سریع وارد کار با دادههای فوتبال میشی. نویسندهها امیدوارن همین ارتباط اولیه باعث بشه بعدها ابزارها و مفاهیم علم داده رو با عمق بیشتری دنبال کنی.
🏈 «این کتاب دادههای پیچیده را به بینشهایی قابلفهم و کاربردی تبدیل میکند. اگر میخواهید درک عمیقتری از فوتبال داشته باشید، خواندنش ضروری است.»
— جان پارک، مدیر عملیات راهبردی فوتبال، Dallas Cowboys
📊 «رویکرد مبتنی بر مطالعه موردی باعث میشود خیلی راحت متوجه شوید برای حل رایجترین مسائل تحلیل فوتبال باید از چه مسیری وارد شوید. چیزی که من واقعاً دوست دارم این است که کتاب همزمان سرشار از مفاهیم علم داده و داستانها و دانستههای جذاب دنیای فوتبال است. برای هر کسی که به کاوش در دادههای فوتبال علاقه دارد، این کتاب یک مطالعه ضروری محسوب میشود.»
— ریچی کاتن، مبلغ و مروج علم داده در DataCamp
⚙️ «این کتاب یک راهنمای عملی برای یادگیری، پیادهسازی و استخراج بینش از تحلیلهای معنادار در دنیای فوتبال است. چه عاشق ورزش باشید و چه یک متخصص داده، مطالعه آن تجربهای فوقالعاده خواهد بود.»
— جان الیور، دانشمند داده
📈 «این کتاب مرجع بسیار خوبی برای یادگیری نحوه استفاده از علم داده در تحلیل فوتبال است. مثالهای آن طیف گستردهای از تکنیکهای مصورسازی داده، آمادهسازی داده و مدلسازی را با استفاده از دادههای واقعی فوتبال آموزش میدهند.»
— رایان دی، دانشمند داده ارشد
🧠 «این کتاب یکی از معدود کتابهایی است که توسط مدرسهای علم دادهای نوشته شده که خودشان هم در صنعت فعالیت میکنند. علاوه بر این، تحلیل فوتبال را همزمان با Python و R آموزش میدهد. مثالها دقیق، حسابشده و واقعاً باکیفیت هستند.»
— دکتر چستر ایسمی، مدرس، دانشمند داده و مشاور
📚 «این افتخار را داشتم که بهعنوان بازبین فنی این کتاب فعالیت کنم. آن را به هر کسی که میخواهد، همانطور که زیرعنوان کتاب وعده میدهد، علم داده را از دریچه ورزش یاد بگیرد، توصیه میکنم.»
— جورج مانت، تحلیلگر مستقل داده و خالق محتوای طنز دادهمحور (Data Memelord)، برگرفته از نقد منتشرشده در Python-Bloggers.
👨💻 درباره نویسندگان
🧠 اریک ایگر رئیس بخش تحقیق، توسعه و نوآوری در Pro Football Focus (PFF) است. او با تکیه بر پیشزمینهاش در ریاضیات کاربردی، روی حل مسائل کمی و دادهمحور برای ۳۲ مشتری لیگ NFL، بیش از ۱۰۵ مشتری NCAA Football و همچنین طیف گستردهای از رسانهها و شرکای تجاری فعالیت میکند.
🎙️ او همچنین یکی از مجریان پادکست PFF Forecast است؛ پادکستی که از طریق PodcastOne و iTunes منتشر میشود و از سال ۲۰۱۸ تاکنون محبوبترین پادکست تحلیل فوتبال در جهان بوده است.
📊 علاوه بر این، از سال ۲۰۲۰ ایگر مسئول تهیه ضرایب و پیشبینیهایی بوده که استیو کورناکی در برنامههایی مانند Football Night in America، Today Show و سایر برنامههای تلویزیونی از آنها استفاده میکند.
🎓 ایگر در University of Nebraska در رشته ریاضیات کاربردی و زیستشناسی ریاضی تحصیل کرد. موضوع رساله دکترای او بررسی این بود که تصادفی بودن (Stochasticity) و فرایندهای غیرخطی چگونه بر پویایی جمعیتها تأثیر میگذارند.
🏫 پس از دریافت دکترا، شش سال نخست فعالیت حرفهای خود را بهعنوان استاد در University of Wisconsin–La Crosse سپری کرد و سپس در سال ۲۰۱۸ بهصورت تماموقت به PFF پیوست.
📚 از آن زمان تاکنون، او از طریق دورههای دانشگاهی، آکادمی Moneyball متعلق به Wharton Sports Analytics and Business Initiative و همچنین دوره آنلاین «Linear Algebra for Data Science in R» در DataCamp، به بیش از ۱۰ هزار دانشجو آمار و ریاضیات آموزش داده است.
🎤 ایگر در گفتوگوهای مختلفی نیز حضور داشته است. از جمله:
📊 ریچارد اریکسون به افراد کمک میکند از ریاضیات و آمار برای درک بهتر جهان و تصمیمگیری مبتنی بر داده استفاده کنند.
🏈 او از کودکی طرفدار دوآتشه تیم Green Bay Packers بوده است و مانند هزاران هوادار دیگر این تیم، بخشی از سهام آن را نیز در اختیار دارد.
🎓 اریکسون تاکنون به بیش از ۲۵ هزار دانشجو آمار آموزش داده است. این آموزشها از طریق دورههای تحصیلات تکمیلی، کارگاههای آموزشی و دورههای DataCamp او در زمینه مدلهای خطی تعمیمیافته (Generalized Linear Models) و مدلهای سلسلهمراتبی (Hierarchical Models) در R ارائه شدهاند.
🐍 او همچنین بهصورت روزمره از Python برای مدلسازی مسائل علمی استفاده میکند.
🔬 اریکسون مدرک دکترای خود را در رشته سمشناسی محیطزیست از Texas Tech University دریافت کرد و در کنار آن گرایش فرعی ریاضیات کاربردی را نیز دنبال کرد.
موضوع رساله دکترای او مدلسازی اثرات آفتکشها در سطح جمعیتها بود؛ یعنی بررسی اینکه استفاده از سموم چگونه میتواند در مقیاس جمعیتی روی گونههای مختلف تأثیر بگذارد.
📈 در طول فعالیت حرفهای خود، روی مجموعهدادههای بسیار متنوعی کار کرده است، از جمله:
🧪 اریکسون در حال حاضر بهعنوان پژوهشگر علمی فعالیت میکند و بیش از ۷۰ مقاله علمی داوریشده در کارنامه خود دارد.
🧀 البته نقش او در زندگی اریک ایگر فقط آموزش R و Python نبوده؛ او یک دستاورد مهم دیگر هم داشته است: اینکه به اریک یاد داده چطور از خوردن Cheese Curds لذت ببرد! 😄
Baseball is not the only sport to use "moneyball." American football teams, fantasy football players, fans, and gamblers are increasingly using data to gain an edge on the competition. Professional and college teams use data to help identify team needs and select players to fill those needs. Fantasy football players and fans use data to try to defeat their friends, while sports bettors use data in an attempt to defeat the sportsbooks.
In this concise book, Eric Eager and Richard Erickson provide a clear introduction to using statistical models to analyze football data using both Python and R. Whether your goal is to qualify for an entry-level football analyst position, dominate your fantasy football league, or simply learn R and Python with fun example cases, this book is your starting place.
Through case studies in both Python and R, you'll learn to:
Table of Contents
Chapter 1. Football Analytics
Chapter 2. Exploratory Data Analysis: Stable Versus Unstable Quarterback Statistics
Chapter 3. Simple Linear Regression: Rushing Yards Over Expected
Chapter 4. Multiple Regression: Rushing Yards Over Expected
Chapter 5. Generalized Linear Models: Completion Percentage over Expected
Chapter 6. Using Data Science for Sports Betting: Poisson Regression and Passing Touchdowns
Chapter 7. Web Scraping: Obtaining and Analyzing Draft Picks
Chapter 8. Principal Component Analysis and Clustering: Player Attributes
Chapter 9. Advanced Tools and Next Steps
Appendix A. Python and R Basics
Appendix B. Summary Statistics and Data Wrangling: Passing the Ball
Appendix C. Data-Wrangling Fundamentals
Who This Book Is For
Our book has two target audiences. First, we wrote the book for people who want to learn about football analytics by doing football analytics. We share examples and exercises that help you work through the problems you’d face. Throughout these examples and exercises, we show you how we think about football data and then how to analyze the data. You might be a fan who wants to know more about your team, a fantasy football player, somebody who cares about which teams win each week, or an aspiring football data analyst. Second, we wrote this book for people who want an introduction to data science but do not want to learn from classic datasets such as flower measurements from the 1930s or Titanic survivorship tables from 1912. Even if you will be applying data science to widgets at work, at least you can learn using an enjoyable topic like American football.
We assume you have a high school background in math but are maybe a bit rusty (that is to say, you’ve completed a precalculus course). You might be a high school student or somebody who has not had a math course in 30 years. We’ll explain concepts as we go. We also focus on helping you see how football can supply fun math story problems. Our book will help you understand some of the basic skills used daily by football analysts. For fans, this will likely be enough data science skills. For the aspiring football analyst, we hope that our book serves as a springboard for your dreams and lifelong learning.
To help you learn, this book uses public data. This allows you to re-create all our analyses as well as update the datasets for future seasons. For example, we use only data through the 2022 season because this was the last completed season before we finished writing the book. However, the tools we teach you will let you update our examples to include future years. We also show all the data-wrangling methods so that you can see how we format data. Although somewhat tedious at times, learning how to work with data will ultimately give you more freedom: you will not be dependent on others for clean data.
Who This Book Is Not For
We wrote this book for beginners and have included appendixes for people with minimal-to-no prior programming experience. People who have extensive experience with statistics and programming in R or Python would likely not benefit from this book (other than by seeing the kind of introductory problems that exist in football analytics). Instead, they should move on to more advanced books, such as 'R for Data Science', 2nd edition by Hadley Wickham et al. (O’Reilly, 2023) to learn more about R, or 'Python for Data Analysis', 3rd edition by Wes McKinney (O’Reilly, 2022) to learn more about Python. Or maybe you want to move into more advanced books on topics we touch upon in this book, such as multivariate statistics, regression analysis, or the Posit Shiny application.
We focus on simple examples rather than complex analysis. Likewise, we focus on simpler, easier-to-understand code rather than the most computationally efficient code. We seek to help you get started quickly and connect with real-world data. To use a quote often attributed to Antoine de Saint-Exupéry: If you wish to build a ship, do not divide the men into teams and send them to the forest to cut wood. Instead, teach them to long for the vast and endless sea.
Thus, we seek to quickly connect you to football data, hoping this connection will inspire and encourage you to continue learning tools in greater depth.
"Transforms complex data into accessible wisdom. A must-read to better understand the game."
- John Park, Director of Strategic Football Operations, Dallas Cowboys
"The case study-drive approach makes it easy to understand how to approach the most common tasks in football analytics. I love how the book is filled with data science and football lore. It's a must read for anyone interested in exploring football data."
- Richie Cotton, Data Evangelist at DataCamp
"A practical guide for learning, implementing, and generating insight from meaningful analytics within the world of football. Fantastic read for sports enthusiasts and data-drive professionals alike."
- John Oliver, data scientist
"This is a great reference to learn how data science is applied to football analytics. The examples teach a wide range of visualization, data wrangling, and modeling techniques using real-world football data."
- Ryan Day, advanced data scientist
"One of the rare books out there written by data science educators that also work in the industry. Football analytics in both Python and R throughout, too! Excellent, thoughtful examples as well."
- Dr. Chester Ismay, educator, data scientist, and consultant
"I had the pleasure to be a tech reviewer for this book and recommend it to anyone interested in, as the subtitle suggests, learning data science through the lens of sports."
- George Mount, Independent data analyst and data memelord, from a review on Python-Bloggers
Eric A Eager is the Head of Research, Development and Innovation at Pro Football Focus (PFF), where he uses his training as an applied mathematician to produce solutions to quantitative problems for 32 National Football League clients, over 105 NCAA Football clients and numerous media clients and contacts. He also co-hosts the PFF Forecast Podcast, which can be found on PodcastOne and iTunes and is the most popular football analytics podcast in the world since 2018. Additionally, Eager supplies odds used by Steve Kornacki on Football Night in America, the Today Show, and other programs since 2020.
He studied applied mathematics and mathematical biology at the University of Nebraska, where he wrote his PhD thesis on how stochasticity and nonlinear processes affect population dynamics. Eager spent his first six years thereafter as a professor at the University of Wisconsin - La Crosse, before transitioning to PFF full-time in 2018. He has since taught statistics and mathematics to over 10,000 students through college-level courses, the Wharton Sports Analytics and Business Initiative’s Moneyball Academy, as well as an online course, “Linear Algebra for Data Science in R” with DataCamp.
Eager has been interviewed by nfl.com’s Ian Rappoport about Cowboys in-game decision making and The Washington Post for commentary about sports analytics. He joined the legendary Peter King’s podcast about fourth-down decisions and is a frequent guest on Cris Collinsworth’s podcast.
Richard A Erickson helps people use mathematics and statistics to understand our world as well as make decisions with this data. He is a lifelong Green Bay Packer fan, and, like thousands of other cheeseheads, a team owner. He has taught over 25,000 students statistics through graduate-level courses, workshops, and his DataCamp courses on Generalized Linear Models in R and Hierarchical Models in R. He also uses Python on a regular basis to model scientific problems.
Erickson received his PhD in Environmental Toxicology with an applied math minor from Texas Tech where he wrote his dissertation on modeling population-level effects of pesticides. He has modeled and analyzed diverse datasets including topics such as soil productivity for the USDA, impacts of climate change on disease dynamics, and improving rural healthcare. Erickson currently works as a research scientist and has over 70 peer-reviewed publications. Besides teaching Eric about R and Python, he also taught Eric to like cheese curds.









