A non-parametric method for measuring the local dark matter density