Return the matrix x without rows and cols containing respectively more than th0 * x.shape[1] and th1 * x.shape[0] NaNs.
Returns : |
|
---|
Example:
>>> import numpy as np
>>> import mlpy
>>> x = np.array([[1, 4, 4 ],
... [2, 9, np.NaN],
... [2, 5, 8 ],
... [8, np.NaN, np.NaN],
... [np.NaN, 4, 4 ]])
>>> y = np.array([1, -1, 1, -1, -1])
>>> x, v0, v1 = mlpy.purify(x, 0.4, 0.4)
>>> x
array([[ 1., 4., 4.],
[ 2., 9., NaN],
[ 2., 5., 8.],
[ NaN, 4., 4.]])
>>> v0
array([0, 1, 2, 4])
>>> v1
array([0, 1, 2])
New in version 2.0.4.
Knn imputing
Parameters : |
|
---|---|
Returns : |
|
>>> import numpy as np
>>> import mlpy
>>> x = np.array([[1, 4, 4 ],
... [2, 9, np.NaN],
... [2, 5, 8 ],
... [8, np.NaN, np.NaN],
... [np.NaN, 4, 4 ]])
>>> y = np.array([1, -1, 1, -1, -1])
>>> x, v0, v1 = mlpy.purify(x, 0.4, 0.4)
>>> x
array([[ 1., 4., 4.],
[ 2., 9., NaN],
[ 2., 5., 8.],
[ NaN, 4., 4.]])
>>> v0
array([0, 1, 2, 4])
>>> v1
array([0, 1, 2])
>>> y = y[v0]
>>> x = mlpy.knn_imputing(x, 2, dist='e', method='median')
>>> x
array([[ 1. , 4. , 4. ],
[ 2. , 9. , 6. ],
[ 2. , 5. , 8. ],
[ 1.5, 4. , 4. ]])
New in version 2.0.4.