This demo demonstrates how to train a server-side model to classify baseball pitch types using Node.js.
It has four parts:
- Baseball sensor training and test data.
- Two ML models that do classification given the sensor data:
- Model that predicts the type of pitch.
- Model that predicts if there was a strike.
- Node.js server that trains a model and serves results over a web socket.
- Web application that displays pitch type learning statistics.
First, prepare the environment:
$ npm install
# or
$ yarn
Next, start the client:
$ npm run start-client
# or
$ yarn start-client
Open the client running at: http://localhost:8080/
In a new shell, start the server:
$ npm run start-server
# or
$ yarn start-server
Two small scripts are provided to test training both of the baseball models without running the client/server demo:
- Pitch Type model:
$ node train_pitch_type.js
- Strike Zone model:
$ node train_strike_zone.js
This demo contains two models. The first is a pitch-type model used in the actual client/server architecture. The other model learns how to call balls and strikes like a major-league umpire. It currently does not have any presentation UI but exists for developers to experiment with.
- Pitch type model - Classifies 7 different pitch types looking at baseball sensor data (pitch-type-model.ts)
- Strike zone model - A model that can learns how to call balls and strikes based on historical umpire calls (strike-zone-model.ts).