How to restore the missing matrix values in Python, knowing that vectors are linearly dependent? For example, in this example, the 2nd vector is 2 times larger than the first one, and the 3rd one is greater than the 2nd vector by 10 (but in fact we do not know this dependence).
import numpy as np nan = np.NaN data = np.array([[1, nan, 5, 6, nan, 20], [2, nan, nan, nan, 4, nan], [20, nan, 100, 120, 40, nan]])
Expected result: the 2nd column can be replaced, possibly based on the distribution for each vector (intuitively present the result as it is)
[[ 1. 7 5. 6. 2. 20.] [ 2. 14 10. 12. 4. 40.] [ 20. 140 100. 120. 40. 400.]]
The matrix may be larger, and the linear relationship between the vectors may not be as clearly expressed as in this example, therefore a universal solution is required.
This requires:
- find dependency coefficients
- fill the gaps
- interpolate remaining gaps
tell me how to do it?