[PYTHON] I want to use the Qore SDK to predict the success of NBA players

This is the article on the 15th day of Machine learning and applied technologies other than deep learning by QuantumCore Advent Calendar 2019.

Thing you want to do

Predict the success of NBA players using time-series information.

This time, we will predict the "points per entry" of Donovan Mitchell, who belongs to Utah Jazz.

Donovan Mitchell (Basketball Reference)

By the way, I am a beginner in basketball.

Assumption

** "Isn't the ups and downs of activity in the season the same every season?" **


For example, "I wasn't doing well at the beginning of the season, but I got back on track in the middle of the season and reached the peak of my activity at the end of the season."

It's a pretty rough assumption, but I tried to see how much I could do with this and the Qore SDK.

Data and forecasts

data

Scraping the Basketball Reference to get the Box Score of the players in each match.

The Bakertball Reference has match data from around 1954, and I scraped all the data for the time being. If you are interested in the content, please contact us.

What to predict

--Explanatory variable: Number of days since the opening --Objective variable: Number of points per entry (PTS / MP)

The scores per Donovan Mitchell entry until mid-November are as follows.

スクリーンショット 2019-12-16 0.03.53.png

This time, we will train using the data of the 18/19 season and validate it by the middle of the 19/20 season (although we will not change the model). After that, we will predict Donovan's success in the actual game.

code

Connect

from  qore_sdk.client import WebQoreClient
client = WebQoreClient(username="", password="p@$$w0rd", endpoint="")

Data preparation

Suppose Donovan.csv has the results of a scraped player.

import pandas as pd
donovan = pd.read_csv('Donovan.csv', parse_dates=['date'], index_col='date')

(Reappearance) </ b>

--Explanatory variable: Number of days since the opening --Objective variable: Number of points per entry (PTS / MP)


#The standard is October 1, before the start of the season.
#The opening day may be better

X = donovan[(datetime.datetime(year=2019, month=10, day=1)>donovan.index) & (donovan.index>datetime.datetime(year=2018, month=10, day=1))].index
X = X - datetime.datetime(year=2018, month=10, day=1)

y = donovan[donovan.index.year==2018]['PTS per mn']

Data split

import sklearn.model_selection as model_selection
X_train, X_valid, y_train, y_valid = model_selection.train_test_split(
    X, y, shuffle=False, random_state=44
)

Learning and prediction

# Train
res = client.regression_train(X=X_train.values, Y=y_train.values)

#Forecast
pred = client.regression_predict(X=X_valid.values)

Validation (confirmation of the name)

import sklearn.metrics as metrics
rmse = metrics.mean_squared_error(y_valid, pred["Y"])**.5
mae = metrics.mean_absolute_error(y_valid, pred["Y"])

print("RMSE=", rmse)
print("MAE=", mae)
print("RMSE/MAE=", rmse/mae)

result

HTTP Error: HTTP Error 500: INTERNAL SERVER ERROR occurred at the time of learning. We will update the article as soon as it is resolved.

Expected challenges

--The assumption is too simple --Maybe factors other than time should be considered ――In the first place, it is strange that the axis of performance evaluation is "the number of points per participation". ――First, let's get the result.

Qore SDK usability

Learning and forecasting with different data sets is certainly easy and easy. I thought that more information should be known about tools such as Reservoir Computing that have advantages but can easily reproduce complex calculations.

On the other hand, it may give the impression of a black box, such as First day article of operation and [Documentation](https://qcore-info.github. You need to understand the explanations such as io / advent-calendar-2019 / index.html # qore_sdk.client.WebQoreClient.classifier_train). In particular, I felt that it would be okay if the documentation had a background / theory explanation page as in the article on the first day.

In any case, I would like to pay tribute to everyone at Quantum Core who devotes their time to developing such tools.

Recommended Posts

I want to use the Qore SDK to predict the success of NBA players
I want to use only the normalization process of SudachiPy
I tried to predict the victory or defeat of the Premier League using the Qore SDK
I want to customize the appearance of zabbix
I want to use the activation function Mish
I tried to predict the price of ETF
I want to use Python in the environment of pyenv + pipenv on Windows 10
I want to grep the execution result of strace
I want to fully understand the basics of Bokeh
I want to use the R dataset in python
I want to increase the security of ssh connections
I want to use Linux commands at the command prompt! Use Linux commands at the command prompt instead of Git Bash
I want to use the latest gcc without sudo privileges! !!
I want to get the operation information of yahoo route
[Python] I want to use the -h option with argparse
I want to judge the authenticity of the elements of numpy array
I want to know the features of Python and pip
Keras I want to get the output of any layer !!
I want to know the legend of the IT technology world
I want to get the name of the function / method being executed
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
I want to output the beginning of the next month with Python
Use PyCaret to predict the price of pre-owned apartments in Tokyo!
Comparison of GCP computing services [I want to use it serverless]
I want to check the position of my face with OpenCV!
Predict the rise and fall of BTC price using Qore SDK
I want to know the population of each country in the world.
I want to use jar from python
I want to use Linux on mac
I want to use IPython Qt Console
I want to display the progress bar
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
[Note] I want to completely preprocess the data of the Titanic issue-Age version-
I don't want to admit it ... The dynamical representation of Neural Networks
(Python Selenium) I want to check the settings of the download destination of WebDriver
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I want to sort a list in the order of other lists
I want to use the Django Debug Toolbar in my Ajax application
I want to express my feelings with the lyrics of Mr. Children
I tried to automatically extract the movements of PES players with software
I want to analyze the emotions of people who want to meet and tremble
I want to leave an arbitrary command in the command history of Shell
I want to stop the automatic deletion of the tmp area with RHEL7
I tried the common story of using Deep Learning to predict the Nikkei 225
Python: I want to measure the processing time of a function neatly
I tried to predict the behavior of the new coronavirus with the SEIR model.
I want to revive the legendary Nintendo combination by making full use of AI and HR Tech!
I want to use complicated four arithmetic operations in the IF statement of the Django template! → Use a custom template
I want to get the path of the directory where the running file is stored.
I want to visualize the transfer status of the 2020 J League, what should I do?
Use the Java SDK of GoogleMapsAPI to get the result of reverse GeoCoding in Japanese.
I tried to touch the API of ebay
I tried to correct the keystone of the image
I want to set a life cycle in the task definition of ECS
I want to use Temporary Directory with Python2
I want to add silence to the beginning of a wav file for 1 second
I want to get League of Legends data ③
I tried to predict the presence or absence of snow by machine learning.