Search code examples
pythonnon-linear-regressionbest-fit-curve

How to find the best fitting function for a y-x non-linear relationship


I have two variables, y being the number of targets achieved and x the number of individuals involved in the operation. The relationship is positive and non-linear (there are only so many individuals you can add before the returns of adding individuals are diminishing), however I am not sure what is the function of x that best predict y.

Using Python, I would like to find the best fitting line/function and identify the maximum of the function to advise how many individuals include in each team to achieve the maximum number of targets [controlling for different variables]

How to do it?


Solution

  • You can use ridge-regression with kernels. kernels helps in transforming linear function to non-linear function without changing its actual form. This is what Graipher was pointing.

    Here is a script, which shows an example to use it.

    Also, these selection comes with experience and understanding. You can also guess closely(eg. which polynomial can fit in), by visualizing the function form.