Artificial Intelligence in NBA Basketball

Data science and machine learning are helping basketball players up their game.

Noah Basketball's camera-based system tracks the arc of a player's shot and other details to evaluate a shooter's skill.

Media credits

 Courtesy Noah Basketball

Marcus Woo, Contributor

(Inside Science) -- Growing up, Rachel Marty would spend hours shooting hoops on her driveway with her dad. Sometimes, a talking computer joined them. In the early years, Marty's dad connected a laptop to a camera, placed them on a cart, and rolled it out onto the street's edge where he surrounded it with traffic cones. From about 25 feet away, the camera could capture the arc of the ball as Marty shot. And with each shot, the computer would announce the angle of the ball's trajectory as it crossed the plane of the hoop.

43. 47. 42.

The optimal entry angle, Marty says, is 45 degrees, and the key is consistency. With this high-tech trainer, she honed her shot over the years as a shooting guard in high school and in college at the University of California, San Diego.

"We were known in the neighborhood as being the weirdos who had this talking machine," she said.

More stories about basketball from Inside Science
The Science of Sneakers: High-Tops vs. Low-Tops
Resting Healthy NBA Players During the Season May Not Help Them in Playoffs
BRIEF: Sleep Helps Players Excel in NBA Finals

But things have changed. In the last few years, high-tech cameras have proliferated across the highest levels of basketball. In 2010, the year Marty graduated from high school, a sports company called Stats, LLC, installed the first SportVU camera systems in NBA arenas. These cameras, perched up with the rafters, track not only the basketball, but also player movement. By 2013, these cameras were in every NBA arena.

The cameras keep a digitized visual record of every game, collecting far more information than could ever be squeezed into a box score. Not only do they track who scores a bucket, for instance, but they also capture every player's position and speed, and whether the score comes from a designed play or a fast break. With so much data, the challenge is to extract useful knowledge -- and help players and coaches to gain every competitive edge possible.

So NBA teams and sports companies have turned to the same powerful tools that are changing so many other industries: machine learning and artificial intelligence. Combined with an unprecedented flood of data, these techniques are revealing new insights about individual players, their teams and their opponents, promising to change how the pros play basketball and how the fans watch it. Even the Martys' shot-arc system has joined the modern NBA, making them weirdos no more.

Noah's sensor records action on the court from a perch above the basket

Courtesy Noah Basketball

Getting on track

The use of machine learning and AI in basketball represents only the latest chapter in the analytics revolution that has been transforming basketball over the last 15 or so years. "It's just a continuation of the spectrum," said Brian Kopp, a sports technology executive who helped Stats, LLC roll out SportVU to the NBA during the early part of the decade.

Of course, teams had long been recording basic statistics such as points, rebounds, and assists. But with analytics, as this statistical approach is called, the stat geeks established the power of math. Wielding statistical tools, they devised new metrics and formulas that more accurately quantified and predicted player and team performance. Tune into almost any basketball game or sports talk show today, and you'll likely hear terms like offensive efficiency and PER (player efficiency rating) rolling off the tongues of analysts as easily as "layup."

That statistical sophistication was widespread in the NBA by the time teams first adopted tracking cameras. But the new deluge of data demanded updated techniques and software. "Along came SportVU, and the data we captured could not be contained in Microsoft Excel," said Kopp.

Meanwhile, increasingly powerful computers were enabling new advances in machine learning, so NBA teams and companies like Stats took advantage. The task was to translate the tracking data into something searchable and digestible, and one major goal, in particular, was to identify specific actions like passes and common plays such as the pick-and-roll, a nuanced maneuver involving the ball-handler, a teammate and two defenders. Machine learning and, more broadly, AI were perfect for the task because, despite mystical and ominous connotations, they're about pattern recognition at their hearts. And pattern recognition is precisely what's required to distinguish, say, the many variants of a pick-and-roll.

For an algorithm to learn these patterns, it must first train on an initial data set in which a human has already identified every play. The more training data there is, the better the algorithm becomes at recognizing patterns in data it's never seen before. The resulting software can then go through all of the tracking data, identify and label every player and play, and create a database of searchable, annotated and animated diagrams of moving dots that represent each player.

Armed with such a database, coaches can, for example, look for how successful a particular play was against a given opponent. They can, if they want, pull up every time LeBron James drove to the hoop and passed to a teammate for an open 3-point shot from the corner. As engineers create more sophisticated tools to analyze this data, the possibilities are endless, said Rajiv Maheswaran, CEO of Second Spectrum, which replaced Stats as the NBA's provider of tracking technology in 2017.

To be clear, these algorithms aren't doing anything humans can't. Humans are really good at recognizing patterns, and teams have long hired staff to review video and identify notable clips for game planning. But it's impractical to sift through hundreds of hours of footage to identify every single pass, shot, rebound, cut, screen and roll. The impact of machine learning is automation, Maheswaran said, freeing up coaches to spend more time strategizing and working with players.

Labeling tracking data is now a standard application of AI in the NBA. But teams and analytics companies want more than tabulating passes and screens. "We want to do a paradigm shift, not just detecting events," said Patrick Lucey, vice president of artificial intelligence at Stats. What they want is contextual information that tells a more complete story of the game, information that requires increasingly detailed data -- numbers like the arc of a shot.

Learning basketball

Marty's talking computer -- and steadily improved versions of it -- would follow her through high school and college, helping to train her teammates and even during her recovery from injury. "The system was growing up with me," she said.

In 2001, her father, Alan, had turned his invention into a company called Noah Basketball, named so because in the Bible, Noah had the perfect “ark.” The newest version, which includes tools to analyze your data and is dubbed Noahlytics, is now used by half of NBA teams, dozens of top college programs, and hundreds of individuals around the country, said John Carter, the company's current CEO. Their system consists of cameras attached 10 feet above the backboard that don't just track the ball's arc, but also its depth and left-right position as it approaches the rim. The system collects data on every shot, adding to a database of more than 150 million shots already recorded during practice sessions around the country.

This data is crucial for the machine learning algorithms that are being incoroporated into the newer systems. The next version, which has already been installed for a few NBA teams, incorporates facial recognition, and can track shots from multiple shooters simultaneously. That allows the system to collect and analyze data from team practices, for example. According to Carter, in the spring the company will introduce another new feature to capture the type of shot a player takes. Using deep learning, a type of machine learning that mimics how a brain learns, the system can identify the particular type of shot taken -- moves that have varying degrees of difficulty that affect the likelihood that the ball goes in.

But whether a shot is made ultimately depends on the ball's trajectory. Rachel Marty, who recently earned a doctorate in bioinformatics, analyzed data from 22 million shots collected by Noah's system to find a more efficient way to evaluate a shooter's skill. Typically, coaches and scouts evaluate shooting ability based on how many shots a player makes during a workout. The more shots a player takes, the better you can assess her true abilities.

Since not every player has the opportunity to take thousands of shots, Marty trained an algorithm to recognize the characteristics of a made shot and predict a player's skill based on only a few attempts. Instead of having players take thousands of shots, coaches and scouts can have them shoot, say, 25. By analyzing the recorded data, Marty's program can provide an accurate estimate of their ability. This capability is also something that will be eventually incorporated into their commercial product, Carter said.

Stats' Lucey, and Panna Felsen, a graduate student at the University of California, Berkeley, have also analyzed how shooters' body positions -- whether the feet were set, or whether they were off balance, for example -- affects a 3-point shot. In a case study with Stephen Curry, they quantified what most fans could already guess: He's in constant motion and shoots a lot of off-balance threes, which makes his uncanny accuracy even more remarkable.

More than just shooting, basketball at the highest levels is an intricate dance of five players on each team moving and reacting as one. To analyze that dance, Stats is developing software that simulates how a team would respond to a given play. The key, Lucey said, is that their deep learning algorithm represents a team not as five individuals but as one entity. The program, called Bhostgusters and still in development, enables a coach to draw up an offensive play on a tablet and see how an opponent might defend it. And because no team is the same, the software also accounts for each team's differences in style and personnel.

Second Spectrum tracks player movement and other game-related data in all 29 NBA arenas.

Courtesy Second Spectrum

Rise of the machines

The impact of machine learning and AI goes beyond X's and O's. Much of Second Spectrum's efforts are to provide a personalized game-watching experience with evermore detailed statistics for the geekiest fans. For example, their CourtVision augmented video technology superimposes graphics and statistics like the probability a player would make a basket, which is based on his past data. You can watch the numbers change above his head as he runs around. The company's goal is for this technology to be widely available on all broadcasts.

An emerging market for these real-time probabilities is sports gambling, which is now legal in most states thanks to a Supreme Court ruling in May that struck down a ban on commercial sports betting. Much of sports gambling involves wagering on specific events during a game, such as whether a certain player will score 20 points in a quarter. To set the odds, gambling houses will need real-time probabilities. It might take a few years for this to develop, Kopp said, but the opportunity is there.

As sports continue to embrace AI, though, will machines soon reign supreme? After all, the best chess and go players in the world are now computers. Would a future NBA game be reduced to a competition of algorithms?

Unlikely, said Dean Oliver, vice president of data science at TruMedia, and considered one of the pioneers of basketball analytics. When it comes to strategy and tactics, you can't solve basketball the way you can solve a game like go. Even complex board games follow rigid rules, while basketball is fluid, with teams constantly adjusting and readjusting to each other. "There is no dominant strategy," he said. "The game is far more robust."

Nor are programs like Bhostgusters meant to replace coaches. What they do, instead, is help coaches check their intuition about a play. "This is not telling the coach what to do. This is assisting the coach in his day-to-day job," Lucey said. "There's a limit on what data can do, because data doesn't capture everything a coach sees and smells."

Indeed, a coach's job is far more than drawing up plays. "The element of coaching that doesn't get played up as much as it should is the ability of the coaches to work with players, to motivate them, to get them to play together," Oliver said.

Although the teams quickest to adopt machine learning do gain an edge, machine learning hasn't revolutionized the game just yet, he added. "What's changed the game of basketball from what it was 10 years ago until now is not the AI and machine learning part of it," he said. "It wouldn't be tremendously simplifying to say that Steph Curry changed basketball." Curry’s devastating ability to shoot from such range has forced teams to abandon strategies that were once conventional wisdom.

The preponderance of 3-pointers in today's NBA owes itself to the recognition that 3-pointers -- along with layups and dunks -- are the most statistically efficient shots. "That's not a machine learning thing," Oliver said. "That is something that was simple math a long time ago."

Ultimately, basketball is still a game played by humans of flesh and blood, and skill, talent and athleticism will always be paramount. It's the randomness that makes sports thrilling, the unexpected plays that no algorithm could ever predict.

As a data scientist, Marty doesn't play basketball as much anymore. But when she visits her parents' home, she tries to take the time to roll out the old shot-tracking system, just like those evenings she used to spend shooting with her dad. "That was our special father-daughter thing," she said.

Trying to hit that 45-degree angle gets addictive, she said. But it's fun, and sometimes it's always good to go back to the basics -- even if that means a talking computer.

Editor's note (Jan. 2, 2019): This story has been edited to use the correct name of the technology known as SportVU. We regret the error.

Author Bio & Story Archive

Marcus Woo is a freelance science writer based in the San Francisco Bay Area who has written for Wired, BBC Earth, BBC Future, National Geographic, New Scientist, Slate, Discover, and other outlets.