-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rudimentary fluid.polynomialregressor
object
#246
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lewardo and congrats on pushing your way through a complete implementation of algo + client, especially with all the boilerplate needed for the dataset stuff. I've not looked in huge detail over the code, but just have general thoughts.
I've warmed a bit to the idea of this object since it was first suggested. I still don't think that higher-degree regressions are (often) all that useful (because of the overfitting), but certainly having a linear regressor is a generally handy thing.
We can think / dream about gaussian process regressors in the future. They're much more complex to implement (we'll need a sampling framework, for one thing) and open all kinds of interface questions (e.g. they produce generative models, which we don't have any precedent for yet).
The problem with refreshing the client's hyperparameters when json is read is meant to have been fixed for the MLPs, so perhaps check the clients for the MLP regressor to see what's done there.
Meanwhile, other thoughts:
- if I ever get round to implementing an echo state network for flucoma, we'll need a linear fitter for that as well, except with Tikhonov regularization added ('ridge regression'). That might also be useful for this object, to mitigate overfitting. Thoughts?
- Can you take me through why we need the
regressors
parameter in the client, rather than just inferring this from the dimensionality of the input dataset? - A UX challenge will be trying to know which
degree
works best for the data in question (and we have parallel challenges for the MLPs, in terms of making principled comparisons between alternative models). There's a few ways of approaching this, but I'm wondering if a separate object that implements something contemporary like Pareto Smoothed Importance Sampling (PSIS) or the Widely Applicable Information Critereon (WAIC) would be interesting / feasible. And how, regardless of algorithm, the interface for a model comparison object could work. If you have opinions / interest in looking into that...(those algos might well be too heavy / Bayes-ey for general use)
I've implemented some of the changes you mentioned, and am working on various others as of writing
I will look into a b-spline regressor to implement as well as this polynomial regressor, as it seems to be more appropriate and have less statistical issues when dealing with noisy data, but I'm also looking into the ridge regression as you suggested as it also seems to be an interesting path to follow |
After a discussion with @tremblap we conjured up a potential UI for 1-N rather than as well as N-N regressors - a simple repeating of the 1 input N times, which could be interesting for the user if they should want to map the same domain to many ranges, let me know what you think of this and I could add it in |
Many thanks. Those changes would seem to bring the object up to readiness, save for all the documentation, testing, help files etc etc etc. If you wanted to be ultra virtuous (and postpone some of the foregoing), you could knock up some C++ tests for this algorithm and add them to the FWIW, adding regularisation for ridge regression should be a very simple change (addition of a single scalar parameter, and an extra term in the linear algebra), at least in the linear case. Anyway, it can be left till later. |
Sounds like Surprising Behaviour to me. Would rather a more explicit workflow with less magic (i.e. user duplicates cols of dataset n times if that's what they want) |
help and examples are definitely on @MattS6464 todo (with yours truly) indeed. |
I'd be more than happy to give it a look! |
@weefuzzy I've been reading into spline regression and wanted to know your thoughts on the interface
|
My inkling is that |
I'll write another client for user-facing interface, for the elegant code reuse behind the scenes the same algorithm can be used with little to no change so I'll make a branch off of here and start the very few edits that are required to make it work, it definitely makes sense to separate the two in terms of user understanding as putting them as one client will just cause confusion |
Hello! So I get an instacrash with the patch above if I do something naughty (the numberbox to 1 to declare 1 dim, yet having 3 dims generated) then fix then predict (= crash) - otherwise it seems to work fine. Also, we spoke about the 1 to many approach - @weefuzzy thought it was magic but did that grow on him? otherwise this is great thanks |
@trembap Could you give me the patch to reproduce this, I'll look into the crash before finishing it off I'm not sure if the idea of 1-N was grown upon, although in terms of implementation it is not something that would be very long to do @AlexHarker since @tremblap is already on bugtesting, would it be possible for you to check for any terrible transgressions in the code, I tried to stay as faithful to the flucoma coding style and formatting as possible, but some aspects may have slipped by me |
format can be clang-format right? codestyle @weefuzzy would have cried I reckon (and @AlexHarker and him might have different tastes :) ) bug patch: take your patch above and follow my instructions. I can help in person. |
It's unclear to me why Owen would have cried - I see no obvious issues with code formatting. |
Yeah, not unduly tearful (though clang-formatting is always appreciated). I didn't warm to the magic, no; much rather we just made it easier to duplicate a dataset column instead |
@weefuzzy while talking to @AlexHarker we came upon the subject of allocators, and hence the |
The simple (or simple-sounding) guideline is: does it ever need to allocate in the audio thread? Eigen's built-in types are hardcoded to use However, where you have matrix multiplications, it's not always obvious where allocation is happening because Eigen's default behaviour is to create temporaries behind the scenes on the assumption that there is aliasing. If you know there isn't aliasing, e.g. (Eventually I'd be inclined to move towards using the ScopedMaps everywhere, so that we can use things like memory arenas for better in-algorithm locality where it makes sense, but that's still a pipedream) Eigen docs on aliasing: https://eigen.tuxfamily.org/dox/group__TopicAliasing.html |
I'll take some time to refactor this to only use Very interesting read about the eigen aliasing, not something I knew about before... |
@tremblap's bug has now been fixed, although the fix will be overwritten when I port the eigen stuffs over to the custom allocator - for now however it seems to be a clean object that works, it could be drip-fed to testers for ui testing and the memory things could be done in the bg while the front-end is road-tested |
The underlying storage for the various matricies has been ported to using the |
Thank you @weefuzzy for the message, it really clarified my understanding of the ScopedEigenMap/FluidTensor memory allocation paradigm, I am aware that this code now needs refactoring for best memory practice, especially during the matrix multiplications - it allocates correctly but copies the data when it needn't. I'll finish this at some point, in the meantime the eureka is really helping me with the LSTM object I'm working on (foreshadowing intended), so thank you for the clarification !! |
Simple N-to-N polynomial regressor, N parallel monovariate polynomial regressors.
DataClient
-inherited member functions all work, includingprint
,read
,write
etc.fluid.MLPRegressor
, withfit
,predictpoint
,predict
etc. ifaceregressors
parameter sets input and output dataset size, namely the number of parallel regressorsdegree
parameter sets the degree of the polynomial regression, currently all regressors are set to the same degree at once@weefuzzy Potential for discussion on and rethinking of the implemented regression algorithm e.g. Gaussian regression may be more appropriate instead of simple polynomial regression, this is just a proof of concept and initial posit for a deterministic alternative to the artificial neural network objects.
tested in max against lewardo/flucoma-max@02d3b22
current issues:
read
ing from json, the parameters update in the algorithm but not in the client so you have to set the parameters (degree, number of regressors) correctly beforeread
ing for it to be recognised by the clientpatch used to test new object