<p dir="auto">I have run into this issue which shows up in a few older reported issues as well, but the current open is a bit different.</p>
<p dir="auto">Using this <a href="https://drive.google.com/file/d/1jX2Xu15MPJcSwPOb07bX7V456BJVE251/view?usp=sharing" rel="nofollow">data</a>, and running this code:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import dask.array as da
from sklearn.cluster import Birch
from sklearn.preprocessing import StandardScaler

data = da.from_zarr(&quot;bug_data.zarr&quot;)
print(&quot;Data Shape: &quot;, data.shape)
print(&quot;Min, Max, Mean, StDev.: &quot;, data.min().compute(), data.max().compute(), data.mean().compute(), data.std().compute())
scaler = StandardScaler()
scaler.fit(data)
data = scaler.transform(data)
print(&quot;Post-Scale - Min, Max, Mean, StDev.: &quot;, data.min(), data.max(), data.mean(), data.std())
clustering = Birch(branching_factor=5, threshold=1e-5, n_clusters=None)
clustering.fit(data)
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">dask</span>.<span class="pl-s1">array</span> <span class="pl-k">as</span> <span class="pl-s1">da</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">cluster</span> <span class="pl-k">import</span> <span class="pl-v">Birch</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">preprocessing</span> <span class="pl-k">import</span> <span class="pl-v">StandardScaler</span>

<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">da</span>.<span class="pl-en">from_zarr</span>(<span class="pl-s">"bug_data.zarr"</span>)
<span class="pl-en">print</span>(<span class="pl-s">"Data Shape: "</span>, <span class="pl-s1">data</span>.<span class="pl-s1">shape</span>)
<span class="pl-en">print</span>(<span class="pl-s">"Min, Max, Mean, StDev.: "</span>, <span class="pl-s1">data</span>.<span class="pl-en">min</span>().<span class="pl-en">compute</span>(), <span class="pl-s1">data</span>.<span class="pl-en">max</span>().<span class="pl-en">compute</span>(), <span class="pl-s1">data</span>.<span class="pl-en">mean</span>().<span class="pl-en">compute</span>(), <span class="pl-s1">data</span>.<span class="pl-en">std</span>().<span class="pl-en">compute</span>())
<span class="pl-s1">scaler</span> <span class="pl-c1">=</span> <span class="pl-v">StandardScaler</span>()
<span class="pl-s1">scaler</span>.<span class="pl-en">fit</span>(<span class="pl-s1">data</span>)
<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-s1">scaler</span>.<span class="pl-en">transform</span>(<span class="pl-s1">data</span>)
<span class="pl-en">print</span>(<span class="pl-s">"Post-Scale - Min, Max, Mean, StDev.: "</span>, <span class="pl-s1">data</span>.<span class="pl-en">min</span>(), <span class="pl-s1">data</span>.<span class="pl-en">max</span>(), <span class="pl-s1">data</span>.<span class="pl-en">mean</span>(), <span class="pl-s1">data</span>.<span class="pl-en">std</span>())
<span class="pl-s1">clustering</span> <span class="pl-c1">=</span> <span class="pl-v">Birch</span>(<span class="pl-s1">branching_factor</span><span class="pl-c1">=</span><span class="pl-c1">5</span>, <span class="pl-s1">threshold</span><span class="pl-c1">=</span><span class="pl-c1">1e-5</span>, <span class="pl-s1">n_clusters</span><span class="pl-c1">=</span><span class="pl-c1">None</span>)
<span class="pl-s1">clustering</span>.<span class="pl-en">fit</span>(<span class="pl-s1">data</span>)</pre></div>
<p dir="auto">I run into this error:</p>
<div class="highlight highlight-text-python-traceback notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Data Shape:  (150000, 2000)
Min, Max, Mean, StDev.:  -1.7028557 5.1015463 0.020574544 0.32617828
/home/nlahaye/.local/lib/python3.8/site-packages/dask/array/core.py:1650: FutureWarning: The `numpy.may_share_memory` function is not implemented by Dask array. You may want to use the da.map_blocks function or something similar to silence this warning. Your code may stop working in a future release.
  warnings.warn(
Post-Scale - Min, Max, Mean, StDev.:  -5.8093686 7.8372993 4.7429404e-11 1.0000027
Traceback (most recent call last):
  File &quot;clustering_bug.py&quot;, line 25, in &lt;module&gt;
    clustering.fit(data)
  File &quot;/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py&quot;, line 517, in fit
    return self._fit(X, partial=False)
  File &quot;/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py&quot;, line 562, in _fit
    split = self.root_.insert_cf_subcluster(subcluster)
  File &quot;/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py&quot;, line 200, in insert_cf_subcluster
    split_child = closest_subcluster.child_.insert_cf_subcluster(subcluster)
  File &quot;/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py&quot;, line 200, in insert_cf_subcluster
    split_child = closest_subcluster.child_.insert_cf_subcluster(subcluster)
  File &quot;/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py&quot;, line 200, in insert_cf_subcluster
    split_child = closest_subcluster.child_.insert_cf_subcluster(subcluster)
  [Previous line repeated 3 more times]
  File &quot;/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py&quot;, line 221, in insert_cf_subcluster
    self.update_split_subclusters(
  File &quot;/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py&quot;, line 179, in update_split_subclusters
    self.init_sq_norm_[ind] = new_subcluster1.sq_norm_
AttributeError: '_CFSubcluster' object has no attribute 'sq_norm_'"><pre class="notranslate">Data Shape:  (150000, 2000)
Min, Max, Mean, StDev.:  -1.7028557 5.1015463 0.020574544 0.32617828
/home/nlahaye/.local/lib/python3.8/site-packages/dask/array/core.py:1650: FutureWarning: The `numpy.may_share_memory` function is not implemented by Dask array. You may want to use the da.map_blocks function or something similar to silence this warning. Your code may stop working in a future release.
  warnings.warn(
Post-Scale - Min, Max, Mean, StDev.:  -5.8093686 7.8372993 4.7429404e-11 1.0000027
Traceback (most recent call last):
  File <span class="pl-s">"clustering_bug.py"</span>, line <span class="pl-c1">25</span>, in <span class="pl-en">&lt;module&gt;</span>
    clustering.fit(data)
  File <span class="pl-s">"/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py"</span>, line <span class="pl-c1">517</span>, in <span class="pl-en">fit</span>
    <span class="pl-k">return</span> <span class="pl-c1">self</span>._fit(X, <span class="pl-v">partial</span><span class="pl-k">=</span><span class="pl-c1">False</span>)
  File <span class="pl-s">"/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py"</span>, line <span class="pl-c1">562</span>, in <span class="pl-en">_fit</span>
    split <span class="pl-k">=</span> <span class="pl-c1">self</span>.root_.insert_cf_subcluster(subcluster)
  File <span class="pl-s">"/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py"</span>, line <span class="pl-c1">200</span>, in <span class="pl-en">insert_cf_subcluster</span>
    split_child <span class="pl-k">=</span> closest_subcluster.child_.insert_cf_subcluster(subcluster)
  File <span class="pl-s">"/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py"</span>, line <span class="pl-c1">200</span>, in <span class="pl-en">insert_cf_subcluster</span>
    split_child <span class="pl-k">=</span> closest_subcluster.child_.insert_cf_subcluster(subcluster)
  File <span class="pl-s">"/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py"</span>, line <span class="pl-c1">200</span>, in <span class="pl-en">insert_cf_subcluster</span>
    split_child <span class="pl-k">=</span> closest_subcluster.child_.insert_cf_subcluster(subcluster)
  [Previous line repeated 3 more times]
  File <span class="pl-s">"/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py"</span>, line <span class="pl-c1">221</span>, in <span class="pl-en">insert_cf_subcluster</span>
    <span class="pl-c1">self</span>.update_split_subclusters(
  File <span class="pl-s">"/home/nlahaye/.local/lib/python3.8/site-packages/sklearn/cluster/_birch.py"</span>, line <span class="pl-c1">179</span>, in <span class="pl-en">update_split_subclusters</span>
    <span class="pl-c1">self</span>.init_sq_norm_[ind] <span class="pl-k">=</span> new_subcluster1.sq_norm_
<span class="pl-en">AttributeError</span>: <span class="pl-s">'_CFSubcluster' object has no attribute 'sq_norm_'</span></pre></div>
<p dir="auto">For simplicity, I extracted this code and stripped away dask-ml wrappers from software I use for clustering, and have been able to successfully complete jobs with other datasets. This data is also a reduced set from a dataset that has many more samples.</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Environment:
OS - CentOS-7
python - v3.8.2
dask - v2022.04.1
sklearn - v1.0.2"><pre class="notranslate">Environment:
OS - CentOS-7
python - v3.8.2
dask - v2022.04.1
sklearn - v1.0.2</pre></div>
<p dir="auto">Please let me know if there is any other info you would like, etc.</p>
<p dir="auto">Thanks!<br>
Nick</p>
<p dir="auto"><em>Originally posted by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/nlahaye/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nlahaye">@nlahaye</a> in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="663267931" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/17966" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/17966/hovercard?comment_id=1112848112&amp;comment_type=issue_comment" href="https://github.com/scikit-learn/scikit-learn/issues/17966#issuecomment-1112848112">#17966 (comment)</a></em></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from sklearn import svm, datasets
from sklearn.model_selection import GridSearchCV, RepeatedKFold
iris = datasets.load_iris()
parameters = {'kernel':('linear', 'rbf'), 'C':[1, 10]}
svr = svm.SVC()
clf = GridSearchCV(svr, parameters, cv=RepeatedKFold())
clf.fit(iris.data, iris.target)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">sklearn</span> <span class="pl-k">import</span> <span class="pl-s1">svm</span>, <span class="pl-s1">datasets</span>
<span class="pl-k">from</span> <span class="pl-s1">sklearn</span>.<span class="pl-s1">model_selection</span> <span class="pl-k">import</span> <span class="pl-v">GridSearchCV</span>, <span class="pl-v">RepeatedKFold</span>
<span class="pl-s1">iris</span> <span class="pl-c1">=</span> <span class="pl-s1">datasets</span>.<span class="pl-en">load_iris</span>()
<span class="pl-s1">parameters</span> <span class="pl-c1">=</span> {<span class="pl-s">'kernel'</span>:(<span class="pl-s">'linear'</span>, <span class="pl-s">'rbf'</span>), <span class="pl-s">'C'</span>:[<span class="pl-c1">1</span>, <span class="pl-c1">10</span>]}
<span class="pl-s1">svr</span> <span class="pl-c1">=</span> <span class="pl-s1">svm</span>.<span class="pl-v">SVC</span>()
<span class="pl-s1">clf</span> <span class="pl-c1">=</span> <span class="pl-v">GridSearchCV</span>(<span class="pl-s1">svr</span>, <span class="pl-s1">parameters</span>, <span class="pl-s1">cv</span><span class="pl-c1">=</span><span class="pl-v">RepeatedKFold</span>())
<span class="pl-s1">clf</span>.<span class="pl-en">fit</span>(<span class="pl-s1">iris</span>.<span class="pl-s1">data</span>, <span class="pl-s1">iris</span>.<span class="pl-s1">target</span>)</pre></div>
<blockquote>
<p dir="auto">AttributeError: 'RepeatedKFold' object has no attribute 'get_n_splits'</p>
</blockquote>
<p dir="auto">I blame me :-/ (also the tests)</p>