Skip to content

BIRCH fails with "'_CFSubcluster' object has no attribute 'centroid_'" #6172

Closed

Description

@Nordwald

This issue occurs to me during an evaluation with growing feature set sizes. In under a second after the call to fit_predict on the BIRCH instance.

Strangely it works for smaller sets of features and does not run out of memory.

For my evaluation I employ 183719 datasets and construct feature sets of growing size. It works with 6 features, but returns this error with 12. I use the version 1.7.

Here is the full stack trace:

Traceback (most recent call last):
  File "clusterer.py", line 27, in score
    labels = self.clusterer.fit_predict(x)
  File "/usr/lib/python2.7/dist-packages/sklearn/base.py", line 371, in fit_predict
    self.fit(X)
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/birch.py", line 424, in fit
    return self._fit(X)
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/birch.py", line 458, in _fit
    split = self.root_.insert_cf_subcluster(subcluster)
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/birch.py", line 193, in insert_cf_subcluster
    subcluster)
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/birch.py", line 212, in insert_cf_subcluster
    closest_subcluster, new_subcluster1, new_subcluster2)
  File "/usr/lib/python2.7/dist-packages/sklearn/cluster/birch.py", line 170, in update_split_subclusters
    self.init_centroids_[ind] = new_subcluster1.centroid_
AttributeError: '_CFSubcluster' object has no attribute 'centroid_'

Sadly I'm not able to reproduce this with an minimal example

Activity

  1. amueller commented on Jan 15, 2016

    @amueller
    Member

    Can you give us the data maybe?

  2. Nordwald commented on Jan 18, 2016

    @Nordwald
    Author

    Hey there,

    the complete dataset covers more than 200 GB of disk space. I noticed the error does even appear with extreme downsampling.

    An example vector:

    [  4.38000000e+02   8.20000000e+01   6.59000000e+02   1.15507200e+05
       0.00000000e+00   0.00000000e+00   2.56000000e+02   1.00400000e+03
       5.03026697e-01   2.00000000e-01   1.04448000e+05   1.71655753e+00
       1.00000000e+01   3.16975143e-01   7.00000000e+00   4.60000000e+01
       1.41077625e+09]
    

    Here is the variance of the data:

    [  7.38731418e+04   1.33597989e+04   2.25672162e+05   3.33621165e+11
       1.28721648e+14   2.12197405e+02   9.80538647e+05   1.48668836e+06
       4.58719820e-02   2.89182579e-02   2.60960022e+13   3.07715641e-01
       5.45002720e+01   3.98338908e-03   3.80032897e+05   5.93208231e+03
       5.29497921e+16]
    

    As you can see, all values are float.

  3. Nordwald commented on Jan 18, 2016

    @Nordwald
    Author

    By the looks of it, sklearn.preprocessing.maxabs_scale seems to resolve the issue. Please consider raising a more specific error for large values with high variances.

  4. modified the milestone: 0.19 on Sep 29, 2016
  5. jnothman commented on Jun 14, 2017

    @jnothman
    Member

    What's the objective of this issue now:

    • try to improve the birch error message?
    • have a generic discussion in documentation on numerical precision issues and how to mitigate them?
  6. jnothman commented on Jun 14, 2017

    @jnothman
    Member

    I don't see it as something that will be fixed for this release.

  7. modified the milestones: 0.20, 0.19 on Jun 14, 2017
  8. modified the milestones: 0.20, 0.21 on Jun 13, 2018
  9. adrinjalali commented on Oct 16, 2018

    @adrinjalali
    Member

    Do we have a working example for the error? I can't reproduce it:

    >>> import numpy as np
    >>> from sklearn.cluster import Birch
    >>> 
    >>> np.random.seed(0)
    >>> X = np.random.multivariate_normal([0]*3,
    ...                                   np.identity(3)*1e70,
    ...                                   size=10)
    >>> Birch().fit_predict(X)
    array([0, 1, 0, 0, 0, 1, 2, 1, 0, 0])
    
  10. added a commit that references this issue on Apr 16, 2019
    802fe4b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions