Free-living cells display strong genome-wide transcriptional responses to changes in individual environmental parameters such as oxygen and temperature. Such transcriptional dynamics are thought to be the basis of a homeostatic response that attempts to reverse the immediate intracellular consequences resulting from the specific change in the environment. I present an alternative interpretation where transcriptional responses reflect a multifaceted behavioral program in response to global changes in the environment that are anticipated to follow the perturbation. This results from the fact that native microbial habitats are highly structured, giving rise to strong correlations between environmental parameters. Over geological timescales, such correlations can be internalized through an "associative learning" process that shapes the connectivity and dynamics of regulatory networks. Such internal models should allow microbes to predict the future trajectory of the environment based on immediate sensory information. We have seen evidence of this anticipatory behavior in responses of the bacterium Escherichia coli to changes in temperature and oxygen that correspond to transitions between the outside environment and the mammalian gastrointestinal tract. These internal representations seem to reflect a true associative learning paradigm, since they show plasticity upon exposure to novel environments. These phenomena increasingly demand that we interpret microbial behaviors from a cognitive perspective, much as we do for understanding animal behaviors. I propose a multi-faceted research program aimed at 1) establishing that these phenomena, indeed, represent cognitive modeling of microbial habitats, 2) revealing the underlying network mechanisms, and 3) exploring associative learning of novel environments through laboratory experimental evolution. The proposed work establishes deep connections between the disparate fields of microbial ecology, regulatory network evolution, and behavior. In so doing, it challenges the dominance of the century-old notion of homeostasis, with fundamental implications for how we understand and control microbial behavior, especially in the context of disease.