Swarms of birds and fish produce well-organized behaviors even though each individual only interacts with their neighbors. Previous studies attempted to derive individual interaction rules using heuristic assumptions from data on captured animals. We propose a machine learning method to obtain the sensorimotor mapping mechanism of individuals directly from captured data. Data on swarm behaviors in fish was captured, and individual positions are determined. The sensory inputs and motor outputs are estimated and used as training data. A simple feedforward neural network is trained to learn the sensorimotor mapping of individuals. The trained network is implemented in the simulated environment and resulting swarm behaviors are investigated. As a result, our trained neural network could reproduce the swarm behavior better than the Boids model. The reproduced swarm behaviors are evaluated in terms of three different measures, and the difference from the Boids model is discussed.