<a id="skfolio-utils-tools-fit-and-predict"></a>

# skfolio.utils.tools.fit_and_predict

<a id="skfolio.utils.tools.fit_and_predict"></a>

### skfolio.utils.tools.fit_and_predict(estimator, X, y, train, test, fit_params, method, column_indices=None)

Fit the estimator and predict values for a given dataset split.

* **Parameters:**
  **estimator** *estimator object implementing ‘fit’ and ‘predict’*
  : The object to use to fit the data.

  **X** *array-like of shape (n_observations, n_assets)*
  : The data to fit.

  **y** *array-like of shape (n_observations, n_factors) or None*
  : The factor array if provided

  **train** *ndarray of int of shape (n_train_observations,)*
  : Indices of training samples.

  **test** *ndarray of int of shape (n_test_samples,) or list of ndarray*
  : Indices of test samples or list of indices.

  **fit_params** *dict*
  : Parameters that will be passed to `estimator.fit`.

  **method** *str*
  : Invokes the passed method name of the passed estimator.

  **column_indices** *ndarray, optional*
  : Indices of columns to select.
    The default (`None`) is to select all columns.
* **Returns:**
  **predictions** *array-like or list of array-like*
  : If `test` is an array, it returns the array-like result of calling
    ‘estimator.method’ on `test`.
    Otherwise, if `test` is a list of arrays, it returns a list of array-like
    results of calling ‘estimator.method’ on each test set in `test`.

