Machine learning for transient recognition in difference imaging with minimum sampling effort