在维度大于 2 的 python 中使用 DBSCAN 有没有简单的方法?

Is there an easy way to use DBSCAN in python with dimensions higher than 2?

我一直致力于使用聚类算法的机器学习项目,并且我正在考虑根据我正在处理的数据使用 scikit-learn 的 DBSCAN 实现。但是,每当我尝试使用我的特征数组 运行 它时,它都会抛出以下错误:

ValueError: Found array with dim 3. Estimator expected <= 2.

这给我的印象是scikit的DBSCAN只支持二维特征。我这样想错了吗?如果没有,是否有支持高维特征数组的 DBSCAN 实现?感谢您提供的任何帮助。

编辑

这是我用于我的 DBSCAN 脚本的代码。这个想法是从许多不同的 CSV 中读取数据,将它们保存到一个数组中,然后将它们转储到一个 pickle 文件中,以便模型可以在将来加载它们和 运行 DBSCAN。

def get_clusters(fileList, arraySavePath):
    # Create empty array
    fitting = [];

    # Get values from all files, save to singular array
    for filePath in fileList:
        df = pd.read_csv(filePath, usecols=use_cols);
        fitting.append(df.values.tolist());

    # Save array to it's own csv file    
    with open(arraySavePath, "wb") as fp:
        pickle.dump(fitting, fp);


def predict_cluster(modelPath, predictInput):
    # Load the cluster data
    with open(modelPath, "rb") as fp:
        fitting = pickle.load(fp);

    # DBSCAN fit
    clustering = DBSCAN(eps=3, min_samples=2);
    clustering.fit(fitting);

    # Predict the label
    return clustering.predict_fit(predictInput);

我认为问题出在“min_samples”参数上。您正在拟合的数据包含 3 features/dimensions,但您已设置“min_samples=2”。 Min_samples 必须等于或大于数据集中的特征数。