필터 지우기
필터 지우기

can reliefF() function deal with NaNs in my matrix?

조회 수: 6 (최근 30일)
Berkan Sesen
Berkan Sesen 2012년 3월 4일
Hello,
I have an (n*m double) matrix, where n (rows) is the number of my samples and m (columns) is the number of my features, which are all discrete (i.e. categorical). The mth column in the data represents my binary outcome. I have tried using relieff() function to return the importance of my predictor features based on my outcome feature.
This is what my data looks like (let's say for simplicity's sake: I have 4 predictor and 1 outcome feature for 3 samples):
matrixdata = [1, 2, 3, NaN, 2; 5, 1, NaN, 2, 1; NaN, 3, NaN, 2, 1];
This is how I call the relieff() on my data:
X = matrixdata(:,1:(end-1));
Ylogical = matrixdata(:,end)== 1;
[ranked,weights] = relieff(X,Ylogical,10, 'categoricalx', 'on');
In this case, does relieff() disregard the NaNs in the data or does it treat NaNs as a separate category of that predictor feature column? Obviously, the former is what I would prefer.
Many thanks, Berkan

채택된 답변

Wayne King
Wayne King 2012년 3월 4일
Hi Berkan, relieff() removes NaNs in both your predictor and response variables. So your preference is the way it is implemented.
  댓글 수: 1
Berkan Sesen
Berkan Sesen 2012년 3월 4일
Hi Wayne, thank you very much, it is a relief!
Best,
berkan

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

추가 답변 (1개)

Berkan Sesen
Berkan Sesen 2012년 3월 5일
Hi, apparently the reliefF function has a sub function removeNaNs(X,Y) as below:
function [X,Y] = removeNaNs(X,Y)
% Remove observations with missing data
NaNidx = bsxfun(@or,isnan(Y),any(isnan(X),2));
X(NaNidx,:) = [];
Y(NaNidx,:) = [];
This effectively gets rid of all rows that contain any NaNs and is not ideal, especially for my case, since it leaves me with X=[] and Y=[] (i.e. no observations!)
How can I tackle this? Would replacing all NaN's with a random category, e.g. 99999, help? By doing this, I am introducing a new node state for all the predictor features so I guess it is not ideal.
Thanks, Berkan

카테고리

Help CenterFile Exchange에서 Get Started with Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by