class museotoolbox.cross_validation.SpatialLeaveOneOut(distance_thresold=None, distance_matrix=None, n_repeats=False, n_splits=False, random_state=False, verbose=False, **kwargs)[source]

Generate a Cross-Validation with a stratified spatial Leave-One-Out method.

  • distance_matrix (numpy.ndarray, shape [n_samples, n_samples]) – Array got from function museotoolbox.vector_tools.get_distance_matrix(inRaster,inVector)

  • distance_thresold (int.) – In pixels.

  • n_repeats (int or False, optional (default=False)) – If False : will iterate as many times as the smallest number of groups. If int : will iterate the number of times specified.

  • random_state (int or False, optional (default=False)) – If int, random_state is the seed used by the random number generator; If None, the random number generator is created with time.time().

  • verbose (integer or False, optional (default=False)) – Controls the verbosity: the higher the value is, the more the messages are detailed.

See also


to get distance matrix and label.


See “Spatial leave‐one‐out cross‐validation for variable selection in the presence of spatial autocorrelation” :

Manage cross-validartion methods to generate the duo valid/train samples.

split(X,y,g) : Function.

Get a memory cross validation to use directly in Scikit-Learn.

saveVectorFiles() : Need default output name (str).

To save as many vector files (train/valid) as your Cross Validation method outputs.

__get_supported_extensions() : Function.

Show you the list of supported vector extensions type when using saveVectorFiles function.

reinitialize() : Function.

If you need to regenerate the cross validation, you need to reinitialize it.


__init__([distance_thresold, …])

Manage cross-validartion methods to generate the duo valid/train samples.

get_n_splits([X, y, groups])

Returns the number of splitting iterations in the cross-validator.



save_to_vector(vector, field[, group, …])

Save to vector files each fold from the cross-validation.

split(X, y[, groups])

Split the vector/array according to y and groups.

Examples using museotoolbox.cross_validation.SpatialLeaveOneOut