hypertools icon indicating copy to clipboard operation
hypertools copied to clipboard

extend cluster function api

Open andrewheusser opened this issue 8 years ago • 5 comments

Add the following to hyp.tools.cluster:

  • Align flag which aligns data before running clustering alg
  • model flag to specify dimensionality reduction alg used if ndims is not None
  • model_params flag to specify model parameters for dimensionality reduction model

@rarredon any interest? similar to what you helped with during the moz sprint :)

andrewheusser avatar Jun 14 '17 15:06 andrewheusser

Also: we should add the normalize flag

jeremymanning avatar Jun 14 '17 21:06 jeremymanning

Sounds good. I should be able to get those implemented this week, maybe even today.

rarredon avatar Jun 20 '17 17:06 rarredon

awesome-- thanks @rarredon!

jeremymanning avatar Jun 20 '17 17:06 jeremymanning

OK, I implemented the new kwargs but I'm getting an error when align=True. It seems kmeans.fit(x) expects x to be a 1 or 2 dimensional array for example, something like,

array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

but tools.align returns a 3 dimensional array; something like

[array([[1, 2, 3],
        [4, 5, 6],
        [7, 8, 9]])]

Do you guys have any ideas for how to handle this?

rarredon avatar Jun 21 '17 21:06 rarredon

I think you want something like this before passing the data to kmeans.fit:

    if type(x) is list:
        x = np.vstack(x)

This should work, let me know!

andrewheusser avatar Jun 22 '17 13:06 andrewheusser