필터 지우기
필터 지우기

How can i convert the numeric numbers stored in a table into the binary numbers with some condition?

조회 수: 2 (최근 30일)
For example , a table having 7 attributes(columns) and 5 elements(rows) is there,
applying some conditions on attribute value like
if value<5 then 0
else 1
different conditions for different attributes.
I want to use this binary database as the input to the neural network.
  댓글 수: 2
kelvina
kelvina 2014년 1월 23일
편집: kelvina 2014년 1월 23일
Actually i am using a diabetes database as the input to the neural network. i need a neural network which is able to classify this data. like based on the attributes(symptoms)value it classifies whether a patient have diabetes or not.
so all the conditions for symptom values need to insert, and all the data of table should be converted into binary stored into the table.

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

채택된 답변

dpb
dpb 2014년 1월 22일
Sure...apply to the choice of attributes by column for your situation, simply a single vector given as example here...
>> x=10*rand(5,1)
x =
2.9783
8.9990
8.6850
1.7939
2.2929
>> x=x>=5
x =
0
1
1
0
0
>>
NB that x>=5 is logical negation of x<5 to get the result as the logical vector. Can, if required, cast to double altho most operations will work without explicitly doing so.

추가 답변 (3개)

Image Analyst
Image Analyst 2014년 1월 22일
Wouldn't this work:
binaryDatabase = yourTable >= 5;
or am I missing something? No looping or "if" tests on each element individually are necessary.
  댓글 수: 2
kelvina
kelvina 2014년 1월 23일
Thanks for reply
but this will not work , i need to keep different conditions for different attributes based on its value.
dpb
dpb 2014년 1월 23일
It's identical to my earlier solution except not in place but creating another corollary variable instead.
If you do intend to have more than two levels, then it's either a multi-step process or, sometimes you can write classification rules as linear transformations or the like wherein the result can be computed as fix() applied to an expression.

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


Greg Heath
Greg Heath 2014년 1월 22일
편집: Greg Heath 2014년 1월 22일
Converting outputs to binary for classification and/or pattern recognition is highly recommended.
However, converting inputs to binary can lose quite a bit of information.
I do not recommend it unless there are mitigating circumstances.
What is the reason for your desire to convert?
Greg
  댓글 수: 1
kelvina
kelvina 2014년 1월 23일
Actually i am using a diabetes database as the input to the neural network. i need a neural network which is able to classify this data. like based on the attributes(symptoms)value it classifies whether a patient have diabetes or not.
and then i need to extract rules from this neural network that how it classifies this data.
Ex. Rule will be in the form:
if cond1=val1 and cond2=val2
then ans=class1
else ans=class2
so this rules will be based on value of input and output relation. And i don't know how to make rules from this numeric value. so if the input and output will be in binary form then it will be easy to form the rules.
if you can say that how i can extract rules from numeric value then it will be more useful to me.

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


Greg Heath
Greg Heath 2014년 1월 23일
I don't believe you are addressing the problem properly.
How many inputs do you have?
Standardize all inputs (zero-mean/unit-variance)
Remove or modify outliers
Design a net using all of the variables. Choose the best of Ntrials candidate designs that vary because of random initial weights. The remaining nets designed below will not be as good.
Rank the inputs using a backward search ending with the "best" variable
Create rules using a forward search starting with the "best" variable.
Simultaneous plots of the error and candidate variables can help decide decision regions.
I am not an expert on creating rules, so you should seriously consider a literature search.
In fact, I think a decision-tree would serve you better.
Hope this helps.
Thank you for formally accepting my answer
Greg

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by