def _fit_and_predict(estimator, X, y, train, test, verbose, fit_params,
                     method):
    # Adjust length of sample weights
    fit_params = fit_params if fit_params is not None else {}
    fit_params = dict([(k, _index_param_value(X, v, train))
                      for k, v in fit_params.items()])

    X_train, y_train = _safe_split(estimator, X, y, train)
    X_test, _ = _safe_split(estimator, X, y, test, train)

    if y_train is None:
        estimator.fit(X_train, **fit_params)
    else:
        estimator.fit(X_train, y_train, **fit_params)
    func = getattr(estimator, method)
    predictions = func(X_test)
    return predictions, test
Fit estimator and predict values for a given dataset split.
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/model_selection/_validation.py/_fit_and_predict