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 个评论
采纳的回答
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
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 个评论
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
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File 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!