Jun 01, 2021 Article blog
This article was reproduced to Know ID: Charles (Bai Lu) knows his personal column
Download the W3Cschool Mobile App, 0 Foundation Anytime, Anywhere Learning Programming >> Poke this to learn
Use Python to simply predict nba results...
It's probably called heat...
After all, it looks like today's circle of friends is brushing NBA-related content...
Although I can't understand...
But that doesn't stop me from predicting a wave...
So,
The following content is purely playful, if there is thunder, count me unlucky...
NBA loyal fans please automatically ignore bad results...
Web disk download link:
https://pan.baidu.com/s/1EwdkonbYY54AxnIgqx9yYA
Password: 1n93
(1) Data selection
The links to get the data are:
https://www.basketball-reference.com/
The data obtained is:
Average performance per team per game;
The average performance of each team's opponents per game;
Comprehensive statistics;
2016-2017 NBA regular season and playoffs per game data;
The 2017-2018 NBA regular season and playoff schedule.
(2) Modeling ideas
The first four items of the data content are used primarily to assess the team's combat effectiveness.
Use the fifth item of the data content, the game schedule, to predict the winning team for each game.
It is used in the form of:
The first three items of the data content and the Elo grade points calculated from the fourth item of the data content are the characteristic vectors for each team.
Introduction to the Elo rating (as in the relevant documents):
For convenience, assume that the winner's increased Elo rating is equal to the Elo grade score reduced by the loser.
In addition, in order to reflect the home advantage, the home team's Elo rating on the original basis of the addition of 100.
(3) Code flow
Initialization of data;
Calculate the Elo grade points for each team (initial value 1600);
Build data sets for each game in the 2016-2017 regular season and playoffs based on the top three data content and Elo ratings;
Use the LogisticRegression function in sklearn to build a regression model;
Using well-trained models to predict the outcome of the 17-18 regular season and playoffs;
Save the forecast results to the 17-18Result .CSV file.
Python version: 3.5.4
Related modules:
Pandas modules, numpy modules, sklearn modules, and some Python-owned modules.
Environment construction
Install Python and add it to the environment variable, and pip installs the relevant modules that are required.
Run the Analysis_NBA_Data.py file in the cmd window:
outcome:
The original purpose of the article was to make the small project about Python pushed by the public more colorful applications. This stimulates the enthusiasm of some Python beginners to learn, and that's all.
The technical content of this article is not high, the model is simple, the data processing method is more casual...
Some of the areas that can be optimized include:
Increase training data (e.g. multi-year data);
Optimize the training model (e.g. other machine learning methods in sklearn or build a network for model training using the deep learning framework).