module calkmeans¶
function calkmeans¶
1 2 3 4 5 6 7 8 9 | |
Calibrating KMeans Clustering Algorithm
This function calibrates the KMeans algorithm for satellite image classification. It can either find the optimal number of clusters (k) by evaluating the inertia over a range of cluster numbers or determine the best algorithm ('lloyd' or 'elkan') for a given k.
Parameters:
image(rasterio.io.DatasetReader): Optical image with 3D data.k(Optional[int]): The number of clusters. If None, the function finds the optimal k.algo(Tuple[str, ...]): Algorithms to evaluate ('lloyd', 'elkan').max_iter(int): Maximum iterations for KMeans (default 300).n_iter(int): Number of iterations or clusters to evaluate (default 10).nodata(float): The NoData value to identify and handle in the data.**kwargs: Additional arguments passed to sklearn.cluster.KMeans.
Returns:
Dict[str, List[float]]: A dictionary with algorithm names as keys and lists of inertia values as values.
Notes:
- If k is None, the function evaluates inertia for cluster numbers from 1 to n_iter. - If k is provided, the function runs KMeans n_iter times for each algorithm to evaluate their performance. - The function handles NoData values using fuzzy matching to account for floating-point precision.
This file was automatically generated via lazydocs.