Loocv error computation OrdinaryRegression
When performing regression tasks using OrdinaryRegression
on moderately large datasets, there is a noticeable slowdown in the fit
step due to the computation of leave-one-out cross-validation errors. Since this computation may not be needed in all cases, can we make it optional?
A small snippet to make it apparent:
import minterpy as mp
import numpy as np
# Set up regressor
mi = mp.MultiIndexSet.from_degree(3, 2, 2.0)
grid = mp.Grid(mi)
regressor = mp.OrdinaryRegression(mi, grid)
# Test data for regression
xvals = np.linspace(-1.0,1.0,30)
X,Y,Z = np.meshgrid(xvals, xvals, xvals)
data_xx = np.c_[X.reshape(-1), Y.reshape(-1), Z.reshape(-1)]
data_yy = np.sin(data_xx[:,0]*data_xx[:,1])
regressor.fit(data_xx, data_yy)
For the above snippet with data of shape (27000,3)
, it takes about 3 mins to compute the loocv_error
, while the least square solving takes only about a second.