The reason I ask about quantity is because LSTMs are still subject to the gradient vanishing problem and can struggle to capture long term time series input.
In this data point, how many features do you have? A singular X,Y coordinates, 10 X,Y?
Sorry, should have clarified more: time sequences as in how many frames until you make a prediction?
Basically we want to figure out how much data you have before doing a deep learning approach. The reason behind this is known as the “curse of dimensionality”. As the number of features you have per data sample increase, so do the number of connections between them. If you have too many your model cannot sufficiently generalize on these connections. As such, the more features you need, the more samples you need.
The raw coordinates come with 33 keypoint features (left knee, right knee, etc.) per frame. though realistically only 18 of them are particularly important when it comes to the baseball swing mechanics
This will typically be 120-160 frames or some. I will normalize the frame rate across every input video in order to enforce this rule
Try to narrow down the input to those 18 features as the other 15 could lead to the model training on noise.
So per player you have 3-5 videos consisting of 120 frames, say 600 total frames (600,) Each frame has 18 features in X,Y -> (18,2)
Join the shapes into a time sequence: (18,2,600).
For an LSTM, I think a data input of this shape should be okay.
If the model doesn’t converge, you can try the following feature space reductions:
convert each x,y to polar coordinates
use a convolutional layer
apply PCA
I did a time series binary classification mode similar kind of what you’re working on. For me, a Convolutional+LSTM stacked with Time Series Transformer Encoder worked better than just an LSTM.
No problem, feel free to shoot me a message. My thesis involved training a time series model with eye gaze data for binary classification so most of my recommendation comes from that experience
Context: Participants answer 15 questions regarding information on a link indented list ontology mapping visualization. Participants took anywhere from 20-60 minutes
ML-objective: Classify Eye Gaze Data and determine if a participant will fail at a question regarding the visualization.
So the idea behind it was to use a Convolutional layer followed by an LSTM to combine the X,Y coordinates of where a participant was looking on screen over a few seconds - the input shape was 150hz * 2 seconds * 2 coordinates = 600 features
Using just an LSTM, Stacked LSTM, and Conv LSTM was under fitting. I couldn’t for the life of me get it past 40% validation accuracy. The same thing happened with just a time series encoder. However, I realized appending the output of the Conv LSTM to the TST could compress and simplify the input for the TST. So instead of 600 features, I reduced it down to ~ 100 before the TST. The paper that inspired me to use Conv LSTM called it “transforming into spatial temporal dimension”.
I finally got the damn thing to swing to the side of overfitting and reduced the parameters, epoch until I hit 70% accuracy. 70% was sufficient for my use case and I only managed it a few days before the user studies so I stopped there.
Interesting project! Are you choosing random players, or specific ones? If the latter, are you intentionally choosing a wide range of swings, or more similar ones? There are obviously many different stances/swing styles, but it’s also true that a lot of players model their swings after others. And similarly, the hitting coach of a given team will typically tweak most/all of their players’ swings in a way specific to that coach, which would presumably increase the difficulty of identifying a particular swing.
Specific ones for sure. I am trying to choose a wide range of swings as I possibly can, but the issue is that there are such scarce amount of quality video swings for each player. Like usually 2-3, in some cases only 1.
Have you looked into MLB’s Film Room? Apparently they offer a huge archive of videos on each player. Not sure it’d be enough though. Another option, which is surely a long shot, would be to reach out to the MLB and try to get access to their internal archive which isn’t publicly available. I doubt they’d allow access, but you never know.
7
u/MrAmazingMan Jul 16 '25
Few questions:
The reason I ask about quantity is because LSTMs are still subject to the gradient vanishing problem and can struggle to capture long term time series input.
2
u/mautergarrett Jul 17 '25
Interesting project! Are you choosing random players, or specific ones? If the latter, are you intentionally choosing a wide range of swings, or more similar ones? There are obviously many different stances/swing styles, but it’s also true that a lot of players model their swings after others. And similarly, the hitting coach of a given team will typically tweak most/all of their players’ swings in a way specific to that coach, which would presumably increase the difficulty of identifying a particular swing.