Modelling of shallow porous aquifers in scenarios where boundary conditions change over time can be a difficult task. In particular, this is true when data modelling is pursued, i.e., models are directly constructed by measured data. In fact, data contain not only the information related to the physical phenomenon under investigation, but also the effects of time-varying boundary conditions, which work as a disturbance. This undesired component conditions the training of data-driven models, as they are fitted by models, which can produce predictions diverging from measured data. Here, a very shallow porous aquifer is modelled in terms of its response to water table to precipitation. The aquifer is characterized by the presence of a low permeability silty top layer covering the lower sandy strata, where the aquifer normally flows. Therefore, when the piezometric level increases up to the low permeability layer, the aquifer changes its behavior from phreatic to confined. This determines the changing boundary condition, which makes the response of the aquifer to rain precipitations complex, as it is related to a two-fold condition: confined or phreatic. The aquifer here is investigated by two machine learning approaches, the earlier based on an evolutionary modeling, and the latter based on artificial neural networks. Evolutionary modeling returned explicit equations with a fitness efficiency up to 0.8 for 1 month for predictions and 0.48 for simulations, while neural networks arrived at 0.85 and 0.28, respectively. The aim of this study is to get an explicit model of the response of the piezometric heights of the aquifer to the precipitations, which is useful for planning the use of groundwater resources.