Implementing Custom GridSearchCV and RandomSearchCV without scikit-learn