-
Notifications
You must be signed in to change notification settings - Fork 2k
Does Accord has gradient free, nonlinear regression classes? #1336
Comments
Hi @dotChris90! Sorry for the delay in answering! However, the answer to your question is yes - there indeed is a method that can be used to implement gradient free regression in Accord.NET. The method is called Cobyla, and its documentation can be found here. However, Cobyla is a quite general optimization algorithm. In order to use it to implement regression, you might need to pass a loss function to it (i.e. sum of squares error) in order to perform parameter optimization. Hope it helps! Cesar |
By the way - I will leave this issue open until an example on how to perform non-linear regression fitting using Cobyla is added to the documentation. |
hi @cesarsouza thanks for Reply. :) oh my god how I could miss this. Yeah it is Logical. I think for a Cobyla solution you have to do a partial apply - is this possible with C#? Do you guys think it would be a good idea to have a "learnGradientFree()" method for NonlinearLeastSquares class? If it is a good idea maybe I could try to implement it. :) |
hey @cesarsouza ok I tried - I followed http://mikehadlow.blogspot.de/2015/09/partial-application-in-c.html and yes C# can partial application like F#. A lot more complex but works. I could construct the total error function and apply Input and Output. Just ... I find that a Gradient free learning / Regression makes it more easy to use ACCORD for other People. Most People I know just want simple Regression Things for measurement fits or sth like that. So this Gradient free Version would be extrem easy to use. So if you think "yes - Gradient free makes sense" : I would offer my help and Code for implement. :) Just Need to select where and if as Extension method or true method. :) |
Yes please! What I had mentioned with "I will leave this issue open until an example on how to perform non-linear regression fitting" was exactly referring to that :-) I would suggest implementing it as a class that implements the NonlinearLeastSquares class. Or better, it could be a modification of this class that, when the gradient function had not been selected, would use Cobyla automatically. However, please feel free to contribute whatever you would like and that you think would make more sense for your application - I can take care of transforming it into a proper class, or finding someone who can take care of transforming it. Thanks! Regards, |
@cesarsouza - ok will deal with it (hopefully) this week. By the way : this is one of the most amazing libraries I saw in .NET world. It has nearly really everything a data Analyst wish. It can *.mat files, Regression, transformations, optim, ... really good (I started my skills with MATLAB - so every language that can read mat is impressive hehe)! Just 1 more question (even not belong to this issue) :
|
Good evening @cesarsouza First of all - Are you using VS or VS Code for implementing ACCORD? So because of this I started to implement a child class (just for try out everything). I started implementing on https://gitlab.com/scienceNumericFun/Accord.Feature_GradientFreeNonlinSQR (you can check - if you feel this is the right way to use). The unit Test at https://gitlab.com/scienceNumericFun/Accord.Feature_GradientFreeNonlinSQR/blob/master/test/Accord.Statistics/Models/Regression/Fitting.Test/NonLinsqrtTester.cs Shows how I think a Gradient free Version could look like. I choose NelderMead because I think I remember that MATLABs Curve Fitting Toolbox is using it for all this non linear Regression. But it was implemented as generic so you can take any other optimization algorithm. :) |
Hello - just made an update for this. I made a git mirror to gitlab of ACCORD.NET and added a sln and some csproj files. They were added for a better Visual Studio Code use. Accord.Core, Accord.Math + Accord.Math.Core and Accord.Statistics. The repo / fork is at https://gitlab.com/dotChris/accord-framework/tree/development My question now is : do you accept pull requests so we somehow can merge it? I think we could merge to the development branch because nothing was deleted and just method and files were added. |
Hello @cesarsouza and dotChris90. I have tried to continue with your work of making a 4 paramter and 5 paramter nonlinear curve fitting gradient free sample for 4PL and 5PL dose response curves:
and
I have good test data, but for the 4PL the results constantly change but once in a while it is correct. I am happy to share all code and test data if I can get help to figure out what is still needed to get convergence. Any help/suggestions would be greatly appreciated. PS - I work for a small biotech start up that simulates the human body outside the body (in vitro) accurately enough to grow human cells quite well and we want to run 4PL and 5PL dose response curves on impedance readings. Take care, Nick |
I have been able to use Cobyla to solve the equation. I do not know how to apply constraints which would definitely help!
|
Are there any "Non-Linear"! and Gradient free Regression classes in Accord?
Hello Accord Team :D
I am very impressed of your work and find amazing that it already works for .NET Core! Amazing work.
Since I come from MATLAB and Python area I was thinking "hey why not ACCORD in Powershell." And actual I tried with Powershell and Powershell Core. It worked. Linear Regression - really, really nice.
But how about non linear models? So tried non-linear - if I compute the Gradient function - ok - i can compute. But how about : Gradient is too complex to compute?
So in other words : does ACCORD give user the possibility to use "http://accord-framework.net/docs/html/T_Accord_Statistics_Models_Regression_NonlinearRegression.htm" (this example) but without! computing the Gradient? And do Accord has some classes for finding the global Minimum of the corresponding Regression error function (not just local)?
Do not worry - just is for curiosity ;)
Wish you all a nice week. :D
The text was updated successfully, but these errors were encountered: