Dimensionality reduction in epidemic spreading models