Replace custom algorithm with SciKit