使用从 finch-clust 库导入的 FINCH() 进行聚类时出现类型错误

问题描述 投票:0回答:1
import numpy as np
from sklearn import datasets
import matplotlib.pyplot as plt
from finch import FINCH

n_samples = 5000
n_clusters = 5
random_state = 42

X, y = datasets.make_blobs(n_samples=n_samples, centers=n_clusters, random_state=random_state)

fin = FINCH()
fin.fit(X)

print(fin.partitions)

我想从 FINCH 算法中打印分区和每个分区中的簇数。但是,我不断收到此错误:

TypeError: FINCH() missing 1 required positional argument: 'data'

FINCH 类的可选参数有:

metric(默认='euclidean'):使用的距离度量

n_jobs (default=1): 启动的进程数 -1 表示使用所有处理器

我不知道为什么类调用需要“数据”值。

尝试此 GitHub 中的这段示例代码https://github.com/eren-ck/finch/blob/main/demo/demo.ipynb

python error-handling cluster-analysis
1个回答
0
投票

有两个看起来相似的雀类库:

finchpyfinch-clust

看起来您已经安装了需要

data
参数的 finch-clust。但使用代码
finchpy

尝试:

pip uninstall finch-clust
pip install finchpy
© www.soinside.com 2019 - 2024. All rights reserved.