Individual computations and social interactions underlying collective
behavior in groups of animals are of great ethological, behavioral, and
theoretical interest. While complex individual behaviors have successfully been
parsed into small dictionaries of stereotyped behavioral modes, studies of
collective behavior largely ignored these findings; instead, their focus was on
inferring single, mode-independent social interaction rules that reproduced
macroscopic and often qualitative features of group behavior. Here we bring
these two approaches together to predict individual swimming patterns of adult
zebrafish in a group. We show that fish alternate between an active mode in
which they are sensitive to the swimming patterns of conspecifics, and a
passive mode where they ignore them. Using a model that accounts for these two
modes explicitly, we predict behaviors of individual fish with high accuracy,
outperforming previous approaches that assumed a single continuous computation
by individuals and simple metric or topological weighing of neighbors behavior.
At the group level, switching between active and passive modes is uncorrelated
among fish, yet correlated directional swimming behavior still emerges. Our
quantitative approach for studying complex, multi-modal individual behavior
jointly with emergent group behavior is readily extensible to additional
behavioral modes and their neural correlates, as well as to other species