You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PERF: speed up iteratively reweighted least squares #2287
I'm looking at this ticket, but something isn't clear. The time in either solver should be dominated by the matrix inversion, which is dominated by either a qr decomp or an svd. This is backed up by the fact that the benchmark lists numpy.linalg.svd as the most expensive operation in statsmodels and SVD via dgelsd in the yatsm solver. If anything, it looks like lstsq is simply faster.
If we include a simplified solver, we'll want to make it use lstsq by default. First, should we try to add numpy.linalg.lstsq as an optional solver in the full Regression case? If yes, then the work looks like this:
Add lstsq as an option for the general solver and make RLM use it.
Benchmark to see if this brings down the runtime.
If no, then create a SimpleRegression class and strip out more of Regression. Unless I'm mistaken, the remaining things we would remove are O(n) where n == number of samples.
@guyrt Solving the least squares problem might be the single most expensive operation, and I don't think we can gain a large amount by changing it, however, the WLS class still has much additional overhead. From the profile it looks like there is still the second call to svd for the rank, and there is a larger amount of time spent in ufunc.reduce.
My guess is that we gain most by stripping all calculations and checks from WLS that are not directly relevant for the IRLS. (no constant check, no rank check, not data handling with label creation, no extra results and not holding on to any temporaries for more than the minimum amount.
I would directly compare the call to WLS with a call to a WLSminimal or wls_minimal, and see what slack we can remove.
I don't think linalg.lstsq is a solution for OLS/WLS fit itself, because it still leaves us with an extra step to calculate the normalized_cov_params in the "standard" usage.
I would prefer GLM as a test case, because I'm currently more familiar with it than with RLM, and more improvements are currently targeted for GLM. However, that's not really important, and I guess the same improvements will be used by all IRLS estimation methods.
Activity
guyrt commentedon Apr 4, 2015
I'm looking at this ticket, but something isn't clear. The time in either solver should be dominated by the matrix inversion, which is dominated by either a qr decomp or an svd. This is backed up by the fact that the benchmark lists numpy.linalg.svd as the most expensive operation in statsmodels and SVD via dgelsd in the yatsm solver. If anything, it looks like lstsq is simply faster.
If we include a simplified solver, we'll want to make it use lstsq by default. First, should we try to add numpy.linalg.lstsq as an optional solver in the full Regression case? If yes, then the work looks like this:
josef-pkt commentedon Apr 5, 2015
@guyrt Solving the least squares problem might be the single most expensive operation, and I don't think we can gain a large amount by changing it, however, the WLS class still has much additional overhead. From the profile it looks like there is still the second call to svd for the rank, and there is a larger amount of time spent in ufunc.reduce.
My guess is that we gain most by stripping all calculations and checks from WLS that are not directly relevant for the IRLS. (no constant check, no rank check, not data handling with label creation, no extra results and not holding on to any temporaries for more than the minimum amount.
I would directly compare the call to WLS with a call to a WLSminimal or wls_minimal, and see what slack we can remove.
I don't think
linalg.lstsqis a solution for OLS/WLS fit itself, because it still leaves us with an extra step to calculate the normalized_cov_params in the "standard" usage.I would prefer GLM as a test case, because I'm currently more familiar with it than with RLM, and more improvements are currently targeted for GLM. However, that's not really important, and I guess the same improvements will be used by all IRLS estimation methods.
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
2 remaining items
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation
PERF: Implement a minimal WLS for use in iterative estimation