How can i convert the numeric numbers stored in a table into the binary numbers with some condition?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
dpb
el 22 de En. de 2014
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.
Más respuestas (3)
Image Analyst
el 22 de En. de 2014
Wouldn't this work:
binaryDatabase = yourTable >= 5;
or am I missing something? No looping or "if" tests on each element individually are necessary.
2 comentarios
dpb
el 23 de En. de 2014
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
el 22 de En. de 2014
Editada: Greg Heath
el 22 de En. de 2014
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
el 23 de En. de 2014
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 comentarios
Ver también
Categorías
Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!