Hide random values from matrix

조회 수: 4 (최근 30일)
Tha saliem
Tha saliem 2018년 3월 11일
댓글: Tha saliem 2018년 3월 11일
hi all
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.
  댓글 수: 5
Tha saliem
Tha saliem 2018년 3월 11일
Hiding doesn't means to remove those values. we can set them to zero. Purpose of this task is to check the Mean Absolute Error (MAE) of an algorithm. Like i am hiding (setting to zero )some values from this matrix and then apply the algorithm (There are 3 to 4 algorithms that i have for prediction of unknown values) and then find out the Mean Absolute Error of algorithm to check error rate with which an algorithm predicts an unknown value.
MAE = |(predicted value) - (Actual Value)| / No of values
I want to ask the ways to hide or set to zero 10% random values from a large matrix. These random values can be from any row or column. Like 2nd value from 1st row. 1st value from 2nd row etc.
10% of matrix means that that as here matrix is 8x9. So its 10% means to hide any 7 values which are not already zero. (72*(10/100))
John D'Errico
John D'Errico 2018년 3월 11일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
John D'Errico 2018년 3월 11일
편집: John D'Errico 2018년 3월 11일
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.
  댓글 수: 3
John D'Errico
John D'Errico 2018년 3월 11일
편집: John D'Errico 2018년 3월 11일
You are the person who needs to choose how to hide them. I suggested a simple scheme is to create a new copy of the array, setting those elements to NaN. But you can choose freely what you do and how you do it. There is no magic here. An algorithm is exactly what you choose to design. Then you write code to implement that algorithm. But there is no single unique way to solve this problem.
What I am saying is that you choose some simple scheme t store the information you need to store. That might be a list of the element indices that are to be hidden. It might be an array that contains NaNs. What ever works for you. At some point of course, you will need that list of elements. But find is a simple way to locate things.
BTW, 1642x1642 is not large.
Tha saliem
Tha saliem 2018년 3월 11일
Yea got it. Thanks alot for explaining.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by