公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.Clusterer.wekaKMeans
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
使用 k-means 演算法叢集資料。可以使用歐幾里得距離 (預設) 或曼哈頓距離。如果使用曼哈頓距離,則會以元件中位數而非平均值計算質心。如需詳細資訊,請參閱:
D. Arthur, S. Vassilvitskii:k-means++:仔細播種的優點。In: Proceedings of the eighteenth annual ACM-SIAM symposium on Discrete algorithms, 1027-1035, 2007.
用量 | 傳回 |
---|
ee.Clusterer.wekaKMeans(nClusters, init, canopies, maxCandidates, periodicPruning, minDensity, t1, t2, distanceFunction, maxIterations, preserveOrder, fast, seed) | 叢集器 |
引數 | 類型 | 詳細資料 |
---|
nClusters | 整數 | 叢集數量。 |
init | 整數,預設值為 0 | 要使用的初始化方法。0 = 隨機、1 = k-means++、2 = canopy、3 = farthest first。 |
canopies | 布林值,預設值為 false | 使用樹冠可減少距離計算次數。 |
maxCandidates | 整數,預設值為 100 | 使用樹冠叢集時,記憶體中可保留的候選樹冠數量上限。T2 距離加上資料特徵,會決定在執行週期性和最終修剪作業前形成多少候選樹冠,這可能會導致記憶體用量過多。這項設定可避免大量候選樹冠耗用記憶體。 |
periodicPruning | 整數,預設值為 10000 | 使用樹冠叢集時,修剪低密度樹冠的頻率。 |
minDensity | 整數,預設值為 2 | 使用樹冠叢集時的最低樹冠密度,低於此值時,系統會在定期修剪期間修剪樹冠。 |
t1 | 浮點值,預設值為 -1.5 | 使用樹冠叢集時要使用的 T1 距離。如果值 < 0,系統會將其視為 T2 的正乘數。 |
t2 | 浮點值 (預設值為 -1) | 使用樹冠叢集時要使用的 T2 距離。如果值 < 0,系統會根據屬性標準差使用啟發式方法。 |
distanceFunction | 字串,預設值為「Euclidean」 | 要使用的距離函式。選項包括:歐幾里得和曼哈頓。 |
maxIterations | 整數,預設值為 null | 疊代次數上限。 |
preserveOrder | 布林值,預設值為 false | 保留執行個體順序。 |
fast | 布林值,預設值為 false | 使用截斷值,加快距離計算速度。停用平方誤差/距離的計算/輸出。 |
seed | 整數,預設值為 10 | 隨機化種子。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eClusters data using the k-means algorithm with either Euclidean (default) or Manhattan distance.\u003c/p\u003e\n"],["\u003cp\u003eIf Manhattan distance is selected, centroids are calculated using the component-wise median instead of the mean.\u003c/p\u003e\n"],["\u003cp\u003eOffers various initialization methods including random, k-means++, canopy, and farthest first.\u003c/p\u003e\n"],["\u003cp\u003eAllows customization of distance calculation, iteration limits, and performance optimization through parameters.\u003c/p\u003e\n"]]],["The k-means algorithm clusters data using either Euclidean or Manhattan distance. Manhattan distance uses component-wise median for centroids, while Euclidean uses the mean. Initialization methods include random, k-means++, canopy, and farthest first. Canopies can be used to optimize distance calculations. Parameters control the number of clusters, pruning frequency, density thresholds, and distance settings. Additional options include limiting iterations, preserving data order, and using a fast distance calculation mode.\n"],null,["# ee.Clusterer.wekaKMeans\n\nCluster data using the k-means algorithm. Can use either the Euclidean distance (default) or the Manhattan distance. If the Manhattan distance is used, then centroids are computed as the component-wise median rather than mean. For more information see:\n\n\u003cbr /\u003e\n\nD. Arthur, S. Vassilvitskii: k-means++: the advantages of careful seeding. In: Proceedings of the eighteenth annual ACM-SIAM symposium on Discrete algorithms, 1027-1035, 2007.\n\n| Usage | Returns |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|\n| `ee.Clusterer.wekaKMeans(nClusters, `*init* `, `*canopies* `, `*maxCandidates* `, `*periodicPruning* `, `*minDensity* `, `*t1* `, `*t2* `, `*distanceFunction* `, `*maxIterations* `, `*preserveOrder* `, `*fast* `, `*seed*`)` | Clusterer |\n\n| Argument | Type | Details |\n|--------------------|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `nClusters` | Integer | Number of clusters. |\n| `init` | Integer, default: 0 | Initialization method to use. 0 = random, 1 = k-means++, 2 = canopy, 3 = farthest first. |\n| `canopies` | Boolean, default: false | Use canopies to reduce the number of distance calculations. |\n| `maxCandidates` | Integer, default: 100 | Maximum number of candidate canopies to retain in memory at any one time when using canopy clustering. T2 distance plus, data characteristics, will determine how many candidate canopies are formed before periodic and final pruning are performed, which might result in exceess memory consumption. This setting avoids large numbers of candidate canopies consuming memory. |\n| `periodicPruning` | Integer, default: 10000 | How often to prune low density canopies when using canopy clustering. |\n| `minDensity` | Integer, default: 2 | Minimum canopy density, when using canopy clustering, below which a canopy will be pruned during periodic pruning. |\n| `t1` | Float, default: -1.5 | The T1 distance to use when using canopy clustering. A value \\\u003c 0 is taken as a positive multiplier for T2. |\n| `t2` | Float, default: -1 | The T2 distance to use when using canopy clustering. Values \\\u003c 0 cause a heuristic based on attribute std. deviation to be used. |\n| `distanceFunction` | String, default: \"Euclidean\" | Distance function to use. Options are: Euclidean and Manhattan. |\n| `maxIterations` | Integer, default: null | Maximum number of iterations. |\n| `preserveOrder` | Boolean, default: false | Preserve order of instances. |\n| `fast` | Boolean, default: false | Enables faster distance calculations, using cut-off values. Disables the calculation/output of squared errors/distances. |\n| `seed` | Integer, default: 10 | The randomization seed. |"]]