nd.classify package¶
-
class
nd.classify.Classifier(clf, feature_dims=[], scale=False)[source]¶ Bases:
object- Parameters
clf (sklearn classifier) – An initialized classifier object as provided by
scikit-learn. Must provide methodsfitandpredict.feature_dims (list, optional) – A list of additional dimensions to use as features. For example, if the dataset has a
'time'dimension and'time'is infeature_dims, every time step will be treated as an independent variable for classification purposes. Otherwise, all time steps will be treated as additional data dimensions just like'x'and'y'.scale (bool, optional) – If True, scale the input data before clustering to zero mean and unit variance (default: False).
-
nd.classify.class_mean(ds, labels)[source]¶ Replace every pixel of the dataset with the mean of its corresponding class (or cluster, or segment).
- Parameters
ds (xarray.Dataset) – The dataset.
labels (xarray.DataArray) – The labels indicating the class each pixel in
dsbelongs to. The label dimensions may be a subset of the dimensions ofds(such as('y', 'x')for a dataset that also contains atimedimension but with time-independent class labels).
- Returns
A dataset with the corresponding mean class values.
- Return type
xarray.Dataset