gnu-octave / statistics

The Statistics package for GNU Octave
GNU General Public License v3.0
24 stars 22 forks source link

ridge: added new function ridge to perform ridge regression #87

Closed AZM999 closed 1 year ago

AZM999 commented 1 year ago

New function ridge with input parameters (y,X,k,flag) that returns the regression coefficients or performs ridge regression of the vector y on the regressor X using ridge parameter k and flag for scaling indications.

AZM999 commented 1 year ago

@pr0m1th3as sure i will add the documentation BISTs and fix the coding style .

actually matlab examples given on the site you mentioned import builtin dataset from Matlab. should i copy the data from the variables into the code or use available data sets in Octave(any suggestions) . also can we copy MATLABs examples directly ?

pr0m1th3as commented 1 year ago

These data sets are available in the statistics package as well.

Do not add your demos as verbatim copies, just write your code to produce the same result. Obviously it won't differ much since you are working with the same data set. It is also useful to add some comment so that the user understands better the demos. If you have access to MATLAB, make sure that your try all options with various inputs so that you can verify that your implementation works as expected under all circumstances.

It is also helpful to add some comment inside the function to clarify what each code block is doing. See some other functions to get an idea. Actually look at the poissfit new function that I pushed yesterday.

pr0m1th3as commented 1 year ago

Any updates on the requested changes?

AZM999 commented 1 year ago

@pr0m1th3as apologies for my inactivity as my pre-final year’s University exams are going on currently .

I have added the help text and BISTs for the implemented function. I was trying to add example/ demo for the function but it seems that either the builtin dataset that i am using has some difference from matlab or my function is missing something that is causing it to through an error for passed parameter.

pr0m1th3as commented 1 year ago

submit your changes on top of this PR so I can review them and help you with the error

AZM999 commented 1 year ago

@pr0m1th3as Added the changes you requested from our earlier conversation , I tried adding the Example using the builtin dataset carbig based on the matlab documentation but it gives an error for vertical dimension mismatch in my code. before my first commit i tested the function by copying the raw data for the values from 'carbig' dataset and that time it worked.

please review the code and suggest changes to fix this

pr0m1th3as commented 1 year ago

See my latest commit

pr0m1th3as commented 1 year ago

Can you make another DEMO with the acetylene dataset?

pr0m1th3as commented 1 year ago

Make sure you commit you new changes on top of this PR, so we can keep track of the function's development

AZM999 commented 1 year ago

@pr0m1th3as Closed the last pr and created a stacked pr on top of this pr to reflect changes, please review and suggest changes if any

pr0m1th3as commented 1 year ago

I have merged this PR and made certain modifications in the coding style, input validation and BISTs, as well as restructured the help texinfo docstring. Please, see the changes I've made so you can adopt them to your coding practices while you are contributing to the statistics package. There are still a few things to work on this function, which I leave them to you. More specifically, you need to add testing blocks under the comment ##Test output to make sure it produces the exact same numbers as MATLAB does. Also, add some comment in the demo code so that the user can better understand how to use this function. I've merged it, so I can produce the online documentation for this functions. Once you make the aforementioned improvements, make a new PR. This can remain closed.