对数据使用 DBSCAN 算法

Use the DBSCAN algorithm on data

我正在尝试在小型数据帧上应用 DBSCAN 算法,以便在之后进行离群值预测。所有列都有数值,但即使我没有空值,我仍然收到相同的错误。

这是我调用算法的代码:

    db = DBSCAN(eps=0.09, min_samples=10).fit(dfc)
    m = loop.LocalOutlierProbability(dfc).fit()
    scores_noclust = m.local_outlier_probabilities
    m_clust = loop.LocalOutlierProbability(dfc, 
    cluster_labels=list(db.labels_)).fit()
    scores_clust = m_clust.local_outlier_probabilities
    print(list(scores_clust))

我收到此错误:

ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

我不明白为什么,因为我没有空值。

根据您的评论,您似乎有一列包含需要转换为整数的对象。

dfc['Idade'] = pd.to_numeric(dfc['Idade']).astype(int)

仅仅做造型是不够的,它只是returns一个新的系列,但它不会修改旧的,你必须明确地这样做。