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

1 次查看(过去 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