skfolio.utils.tools.fit_and_predict#
- skfolio.utils.tools.fit_and_predict(estimator, X, y, train, test, fit_params, method, column_indices=None)[source]#
Fit the estimator and predict values for a given dataset split.
- Parameters:
- estimatorestimator object implementing ‘fit’ and ‘predict’
The object to use to fit the data.
- Xarray-like of shape (n_observations, n_assets)
The data to fit.
- yarray-like of shape (n_observations, n_factors) or None
The factor array if provided
- trainndarray of int of shape (n_train_observations,)
Indices of training samples.
- testndarray of int of shape (n_test_samples,) or list of ndarray
Indices of test samples or list of indices.
- fit_paramsdict
Parameters that will be passed to
estimator.fit.- methodstr
Invokes the passed method name of the passed estimator.
- column_indicesndarray, optional
Indices of columns to select. The default (
None) is to select all columns.
- Returns:
- predictionsarray-like or list of array-like
If
testis an array, it returns the array-like result of calling ‘estimator.method’ ontest. Otherwise, iftestis a list of arrays, it returns the list of array-like results of calling ‘estimator.method’ on each test set intest.