fix(umap): LazyFrame.sample not available in Polars 1.42, use DataFrame.sample after collect
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
"""Cluster views: overview, detail, globe flows, and the clustering pipeline."""
|
"""Cluster views: overview, detail, globe flows, and the clustering pipeline."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
@@ -382,12 +382,11 @@ def _run_clustering_pipeline(run, store, ds_id, feature_columns, algorithm,
|
|||||||
|
|
||||||
if len(num_cols) >= 2:
|
if len(num_cols) >= 2:
|
||||||
if n_total > MAX_UMAP_TRAIN:
|
if n_total > MAX_UMAP_TRAIN:
|
||||||
run.progress_msg = f'UMAP 采样 {MAX_UMAP_TRAIN}/{n_total} 实体训练...'
|
run.progress_msg = f'UMAP 采样 {MAX_UMAP_TRAIN}/{n_total} 行训练...'
|
||||||
run.save(update_fields=['progress_msg'])
|
run.save(update_fields=['progress_msg'])
|
||||||
df_sample = lf.sample(n=MAX_UMAP_TRAIN, seed=RANDOM_SEED).collect(streaming=True)
|
# LazyFrame.sample() is unavailable in Polars 1.42 — collect then sample
|
||||||
df_umap = lf.collect(streaming=True)
|
df_sample = df_umap.sample(n=MAX_UMAP_TRAIN, seed=RANDOM_SEED)
|
||||||
else:
|
df_sample = df_umap
|
||||||
df_umap = lf.collect(streaming=True)
|
|
||||||
|
|
||||||
umap_components = 3 # try 3D first
|
umap_components = 3 # try 3D first
|
||||||
coords = None
|
coords = None
|
||||||
|
|||||||
Reference in New Issue
Block a user