patchGNU Octave - Patches: patch #10008, [octave forge] (statistics) Add...

 
 

patch #10008: [octave forge] (statistics) Add function inconsistent

Submitter:  None
Submitted:  Fri 01 Jan 2021 06:12:26 PM UTC
   
 
Category:  Forge : new function Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Originator Email:  -email is unavailable-
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 25 Jan 2021 07:47:01 PM UTC, comment #7: 

I've fixed a few style thingies here:
http://hg.code.sf.net/p/octave/statistics/rev/c04ff605be76
which gave me an opportunity to add a patch report no. (which I forgot at the initial push).

Closing report.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 17 Jan 2021 01:37:48 PM UTC, comment #6: 

Pushed here:
http://hg.code.sf.net/p/octave/statistics/rev/6f57f4fddafe

Status -> Ready for test

I tested with a few Matlab examples but want to try a bit more. But there are many distractions ...

You did a good job w.r.t. coding style,texinfo and tests, excellent, thanks!

Philip Nienhuis <philipnienhuis>
Group Member
Tue 05 Jan 2021 03:21:59 PM UTC, comment #5: 

New patch, it should be ok now. I added some new tests too.

(file #50658)

Anonymous
Sun 03 Jan 2021 11:22:08 PM UTC, comment #4: 

In fact the fisheriris data set has been in the statistics package since 2014, see
https://sourceforge.net/p/octave/statistics/ci/default/tree/inst/fisheriris.txt

If you want to change its format to be a .mat file instead of plain text, that's fine with me. Cf.
https://savannah.gnu.org/patch/?func=detailitem&item_id=9229

Nir Krakauer <nir_krakauer>
Sun 03 Jan 2021 09:56:32 PM UTC, comment #3: 

About the code formatting: no problem. I have just found this: https://wiki.octave.org/Octave_style_guide .

About the nested function: I used the nested function exactly to avoid the duplication of data. I think that Octave creates a copy of the input arguments every time the function is called, which, for a recursive function, means many times at once. I can relocate it inside the main, if you think it will make it more readable.

About the dataset: it is the most famous Iris dataset ( https://en.wikipedia.org/wiki/Iris_flower_data_set ) published by Fisher in 1936. It is included in R and scikit-learn (a BSD licenced package for Python) and it is, as far as I know, in public domain. However I am going to include a reference to the UCI Machine Learning Repository in the file, just to make its provenance clear.

I think that I will be able to upload the updated versions in a few days.

Anonymous
Sun 03 Jan 2021 08:13:23 PM UTC, comment #2: 

Thanks for this contribution.

Remarks after a brief look (just coding style etc, not inner working of the function):

  • The first line after the function call definitions (@deftypefn) should end with a period. The functions we use to extract the texinfo for docs and the function listing on the octave-forge site etc. rely on it (although they aren't that fragile).
  • Having a nested function somewhere seemingly at random in the middle of the function code can be hard to follow. However, AFAIK we have no coding standard for that yet. Could you make it a subfunction outside the main function body (I guess you'd have to add 'Z' as input arg), or otherwise put it at the end or start of the main function body?
  • All comment lines should start with double hashes ('##').
  • Consistently use one space between function name and opening parenthesis and after a comma separating arguments or values. (Except when concatenating between square brackets).
  • I'm a bit wary of copying data the competition also uses (although they seem to originate from a public site - have you checked the licensing conditions there?), especially when using it in a BIST literally.
  • You can already add 'cluster' in the seealso macro.


Philip Nienhuis <philipnienhuis>
Group Member
Sun 03 Jan 2021 02:38:36 PM UTC, comment #1: 

Just added a new version of the patch.
Brief changelog:
  * added a test
  * some rewording for the help

(file #50629)

Anonymous
Fri 01 Jan 2021 06:12:26 PM UTC, original submission:  

The function "inconsistent" computes the inconsistency coefficient for each link of a hierarchical cluster tree, which is usually the output of the "linkage" function.

This is an example from the MATLAB documentation (where I substituted "gallery('uniformdata',[10 2], 12)" with its values for reproducibility):

>> X = [.5266 .3142; .7502 .4603; .6655 .6940; .9640 .0014; .1082 .5530; .9314 .8254; .6781 .3419; .9827 .7046; .6147 .0470; .5802 .9174];
>> Y = pdist(X);
>> Z = linkage(Y, 'single');
>> inconsistent(Z)
ans =

   0.13124   0.00000   1.00000   0.00000
   0.13863   0.00000   1.00000   0.00000
   0.14632   0.01088   2.00000   0.70711
   0.23913   0.00000   1.00000   0.00000
   0.21391   0.05208   3.00000   0.66564
   0.26496   0.02317   2.00000   0.70711
   0.23640   0.09138   3.00000   0.65875
   0.32443   0.03936   2.00000   0.70711
   0.41701   0.09156   2.00000   0.70711


This patch was generated by the command "hg -r".

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #50658:  inconsistent.3.patch added by None (5KiB - text/x-patch - more tests - better coding style)
file #50629:  inconsistent.2.patch added by None (4KiB - text/x-patch - new version with one test and some minor tweaks)
file #50599:  inconsistent.patch added by None (4KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by philipnienhuis
  • -email is unavailable- added by nir_krakauer (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-25 philipnienhuis StatusReady For Test Done
        Open/ClosedOpen Closed
    2021-01-17 philipnienhuis StatusNone Ready For Test
    2021-01-05 None Attached File- Added inconsistent.3.patch, #50658
    2021-01-04 philipnienhuis Carbon-Copy- Added philipnienhuis
    2021-01-03 None Attached File- Added inconsistent.2.patch, #50629
    2021-01-01 None Attached File- Added inconsistent.patch, #50599

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code