fuzzyclust.incomplete.make_mcar#

fuzzyclust.incomplete.make_mcar(X, missing_rate=0.2, random_state=None, return_mask=False)[source]#

Remove values missing completely at random (MCAR) from a data matrix.

Every entry is deleted independently with probability missing_rate and replaced by NaN. Two repairs keep the result usable by every strategy of IncompleteFCM: a sample that would lose all its features keeps one randomly chosen value, and a feature that would be lost everywhere keeps one randomly chosen sample. The deletion mechanism is the one of the experiments of Hathaway and Bezdek (2001).

Parameters:
Xarray_like of shape (n_samples, n_features)

Complete data.

missing_ratefloat, default=0.2

Probability of every entry being missing, in [0, 1).

random_stateint, RandomState instance or None
return_maskbool, default=False

Also return the boolean mask of the deleted entries.

Returns:
X_missingndarray of shape (n_samples, n_features)

Copy of X with NaN at the deleted entries.

maskndarray of bool of shape (n_samples, n_features)

Only when return_mask=True.

Examples

>>> import numpy as np
>>> from fuzzyclust.incomplete import make_mcar
>>> X = np.arange(20.0).reshape(10, 2)
>>> Xm, mask = make_mcar(X, missing_rate=0.3, random_state=0, return_mask=True)
>>> bool(np.isnan(Xm).sum() == mask.sum()), bool((~mask).any(axis=1).all())
(True, True)

Examples using fuzzyclust.incomplete.make_mcar#

Clustering incomplete data: the four strategies of Hathaway and Bezdek

Clustering incomplete data: the four strategies of Hathaway and Bezdek

Imputation by clustering: accuracy of the completed values

Imputation by clustering: accuracy of the completed values