JB5.jpeg

Polymer Mechanics and Machine Learning

Neural Network Analysis of Hammer Throw Distance using PyTorch

Summary In this example I have used a “Sequential” neural network model to solve the regression problem of how far a hammer will fly given an initial velocity and angle. A sequential model is linear stack of layers, and allows you to create a Neural Network (NN) by simply adding layers sequentially. Both PyTorch and Keras are popular frameworks for building these NN models. Compared to Kears, the PyTorch approach is exposes more details which makes it more flexible and suitable for complex and dynamic models.

Neural Network Analysis of Hammer Throw Distance using Scikit-Learn

Summary The MLPRegressor in scikit-learn is a powerful tool for performing regression tasks using a multi-layer perceptron (MLP), which is a type of artificial neural network. It is a supervised learning algorithm that learns a function that maps input data to continuous output values. It can model complex relationships between features and the target variable. Code Location You can find the code in this example here. import matplotlib.pyplot as plt import numpy as np from sklearn.

Neural Network Analysis of Hammer Throw Distance using TensorFlow Keras

Summary The Keras Sequential model is a simple and straightforward way to build neural networks in Keras, a high-level neural networks API running on top of TensorFlow. The Sequential model allows you to stack layers sequentially, meaning each layer has exactly one input tensor and one output tensor. You start by creating an instance of the Sequential model, then add layers to it one by one. Each layer, such as Dense (fully connected), Convolutional, or LSTM (Long Shor-Term Memory), is added using the add method.

Scikit-Learn Regression of Hammer Throw Distance

Linear Regression Linear regression is a fundamental statistical method used in machine learning to model the relationship between a dependent variable (often called the target or outcome) and one or more independent variables (often called features or predictors). In our example of hammer throwing we have 2 inputs (velocity and angle), and one output (distance). The regression equation therefore becomes: $d = b_0 + b_1 v + b_2 \alpha$. The goal of linear regression is to find the values of the coefficients ($b_i$) that minimize the difference between the predicted values and the actual values.

Hammer Throw: Generate Training Data

Training Data All machine learning algorithms require data for training the model. In this example, we can use physics calculations to generate a dataset with two input variables: velocity and angle, and one output variable: flight distance. The following Python code creates an input file named data_X.csv containing the input variables, and a results file with the flight distance. These files will be used in subsequent machine learning demonstrations. import math import numpy as np import csv def calc_distance(angle, velocity): # fixed input parameters g = 9.

Hammer Throw Distance Calculation when No Air Drag

Introduction Welcome to the first article in my series on calculating the distance a projectile will travel based on its initial velocity and angle. Using hammer throwing, an Olympic track and field sport, as an example, I will demonstrate these calculations. However, the principles apply equally well to baseball and other sports. Code Location You can find the code in this example in this file. For simplicity, I will focus solely on predicting the distance the hammer will fly, leaving the complete flight path for later discussion.