Hide random values from matrix
10 views (last 30 days)
Show older comments
Commented: Tha saliem on 11 Mar 2018
i have matrix A (8x9):
A = [0,2,0,0,1,2,0;3,0,4,5,0,0,1;0,0,2,0,3,0,0;0,5,0,3,0,0,2;4,0,1,0,4,5,0;0,2,0,0,4,0,0;3,0,0,0,0,0,2;3,0,1,1,2,1,3]
i have to find mean absolute error. for which i have to hide 10% values from this matrix and then find those values using algorithm and then find out its MAE. How can i can hide random values from the matrix? As actual matrix is quite large.
Hiding means absolutely whatever you want it to mean.
It is you who needs to design the algorithm, and write the code. So you are the one who needs to design the algorithm, and chose how to flag or indicate which values are hidden. There is no magical tool in MATLAB to "hide" a number in an array.
Edited: John D'Errico on 11 Mar 2018
There are lots of ways you could "hide" something.
Simplest would be to make a copy of your matrix. Then choose some subset of the values to "hide". (help randperm) Do the hiding step by replacing them with NaN.
Finally, choose some algorithm to infer the NaN elements from the rest of the data. Personally, I'd use my own inpaint_nans utility, but I doubt using a tool from the File Exchange is an acceptable solution for a homework problem. But there are lots of ways you can impute values for those missing elements. I can think of at least a few, so you need to think here.
Finally, once you have computed the predictions for the hidden elements, compute the differences between the original values and the predictions. Take the absolute values, and then compute the mean (thus MAE: Mean Absolute Error.) The MAE only applies to the originally hidden elements of course.
More Answers (0)
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!