Converts a linkage matrix generated by MATLAB(TM) to a new linkage matrix compatible with this module.

The conversion does two things:

  • the indices are converted from 1..N to 0..(N-1) form, and
  • a fourth column Z[:,3] is added where Z[i,3] represents the number of original observations (leaves) in the non-singleton cluster i.

This function is useful when loading in linkages from legacy data files generated by MATLAB.


Z : ndarray

A linkage matrix generated by MATLAB(TM).


ZS : ndarray

A linkage matrix compatible with scipy.cluster.hierarchy.