sklearn.cluster.compute_optics_graph?

sklearn.cluster.compute_optics_graph(X, *, min_samples, max_eps, metric, p, metric_params, algorithm, leaf_size, n_jobs)

[源碼]

計算OPTICS可達圖

用戶指南中閱讀更多內容。

參數 列表
X array, shape (n_samples, n_features), or (n_samples, n_samples) if metric=’precomputed’
如果metric=’precomputed’,則是特征數組,或樣本之間的距離數組
min_samples int > 1 or float between 0 and 1 (default=5)
一個點被視為核心點的鄰域樣本數。此外,上下陡峭地區不能有超過min_samples連續的非陡峭點。表示為樣本數的絕對值或一小部分(四舍五入至少為2)。
max_eps float, optional (default=np.inf)
兩個樣本之間的最大距離,其中一個被視為另一個樣本的鄰域。np.inf默認值將識別所有規模的聚類;減少max_eps會縮短運行時間。
metric str or callable, optional (default=’minkowski’)
用于距離計算的度量。任何來自scikit-learn或scipy.spatial.distance的度量都可以使用。 如果度量是可調用的函數,則在每對實例(行)上調用它,并記錄結果值。可調用應該以兩個數組作為輸入,并返回一個值,指示它們之間的距離。這適用于Scipy’s度量,但比將度量名稱作為字符串傳遞的效率要低。如果度量是“precomputed”,則假定X是距離矩陣,并且必須是平方的。
度量的有效值是:
scikit-learn里面:[‘cityblock’, ‘cosine’, ‘euclidean’, ‘l1’, ‘l2’, ‘manhattan’]
scipy.spatial.distance里面:[‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘correlation’, ‘dice’, ‘hamming’, ‘jaccard’, ‘kulsinski’, ‘mahalanobis’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘yule’]

有關這些度量的詳細信息,請參閱scipy.spatial.distance的文檔。
p int, optional (default=2)
來自sklearn.metrics.pairwise_distances的Minkowski度量的參數。當p=1時,這相當于使用曼哈頓距離(L1); 當p=2, 相當于使用歐幾里得距離(L2)。對于任意p,使用minkowski_distance (l_p)。
metric_params dict, optional (default=None)
度量函數的附加關鍵字參數。
algorithm {‘auto’, ‘ball_tree’, ‘kd_tree’, ‘brute’}, optional
用于計算最近鄰居的算法:
- ‘ball_tree’將會使用BallTree
- ‘kd_tree’將會使用KDtree
- ‘brute’將會使用蠻力搜索
- ‘auto’將嘗試根據傳遞給fit方法的值來確定最合適的算法。(默認)

注意:擬合稀疏輸入將覆蓋此參數的設置,使用蠻力法。
leaf_size int, optional (default=30)
傳遞給BallTree 或者 KDTree。這會影響構造和查詢的速度,以及存儲樹所需的內存。最優值取決于問題的性質。
n_jobs int or None, optional (default=None) 要為鄰居搜索的并行作業數。None意味1, 除非在joblib.parallel_backend環境中。-1指使用所有處理器。有關詳細信息,請參Glossary
屬性 說明
ordering_ array, shape (n_samples,)
樣本索引的聚類排序列表。
core_distances_ array, shape (n_samples,)
每個樣本成為一個核心點的距離,按對象順序索引。有一個inf的距離點永遠不會成為核心。使用clust.core_distances_[clust.ordering_]按聚類排序進行訪問。
reachability_ array, shape (n_samples,) 每個樣本的可達距離,按對象順序索引。使用clust.achaability_[clust.order_]按聚類順序訪問。
predecessor_ array, shape (n_samples,) 指出一個樣本是從中得到的,并按對象順序進行索引。種子點有-1的前身。

參考

1 Ankerst, Mihael, Markus M. Breunig, Hans-Peter Kriegel, and J?rg Sander. “OPTICS: ordering points to identify the clustering structure.” ACM SIGMOD Record 28, no. 2 (1999): 49-60.