Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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
kelvina
kelvina el 23 de En. de 2014
Editada: kelvina el 23 de En. de 2014
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.

Iniciar sesión para comentar.

Respuesta aceptada

dpb
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
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
kelvina
kelvina el 23 de En. de 2014
Thanks for reply
but this will not work , i need to keep different conditions for different attributes based on its value.
dpb
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.

Iniciar sesión para comentar.


Greg Heath
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
  1 comentario
kelvina
kelvina el 23 de En. de 2014
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.

Iniciar sesión para comentar.


Greg Heath
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

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by