Exchange-correlation functionals from ab initio electron densities