Count a specific number in a set of attributes

Shubha
New Altair Community Member
Hi,
I have a set of attributes and I need to create a new attribute which counts the number of zeros appearing in all the rows over the set of attributes.
I tried some like the below.
Though the AttrbuteAggregation operator has the COUNT function, it cannot count the occurance of a specific number over the set of attributes.
Thanks for your help,
Shubha
I have a set of attributes and I need to create a new attribute which counts the number of zeros appearing in all the rows over the set of attributes.
I tried some like the below.
<operator name="Root" class="Process" expanded="yes">
<operator name="ExampleSetGenerator" class="ExampleSetGenerator">
<parameter key="target_function" value="random"/>
<parameter key="number_examples" value="10"/>
</operator>
<operator name="Real2Integer" class="Real2Integer">
<parameter key="round" value="true"/>
</operator>
<operator name="AttributeAggregation" class="AttributeAggregation" breakpoints="before">
<parameter key="attribute_name" value="new"/>
<parameter key="aggregation_attributes" value="att.*"/>
<parameter key="aggregation_function" value="count"/>
</operator>
</operator>
Though the AttrbuteAggregation operator has the COUNT function, it cannot count the occurance of a specific number over the set of attributes.
Thanks for your help,
Shubha
Tagged:
0
Answers
-
Hi Shubha,
Nice problem for regex folk! Does this do what you want? Haven't checked it thoroughly, but you get the idea..<operator name="Root" class="Process" expanded="yes">
Good weekend to all!
<operator name="Set what you want to count" class="SingleMacroDefinition">
<parameter key="macro" value="Look_for"/>
<parameter key="value" value="-1"/>
</operator>
<operator name="ExampleSetGenerator" class="ExampleSetGenerator">
<parameter key="target_function" value="random"/>
<parameter key="number_of_attributes" value="10"/>
</operator>
<operator name="IdTagging" class="IdTagging">
</operator>
<operator name="Real2Integer" class="Real2Integer">
<parameter key="round" value="true"/>
</operator>
<operator name="IOStorer" class="IOStorer">
<parameter key="name" value="bla"/>
<parameter key="io_object" value="ExampleSet"/>
<parameter key="remove_from_process" value="false"/>
</operator>
<operator name="Numerical2Polynominal" class="Numerical2Polynominal">
</operator>
<operator name="Replace what you are counting with A" class="Replace">
<parameter key="attributes" value=".*"/>
<parameter key="replace_what" value="%{Look_for}"/>
<parameter key="replace_by" value="A"/>
</operator>
<operator name="Get rid of all else" class="Replace">
<parameter key="attributes" value=".*"/>
<parameter key="replace_what" value="A[0-9]+|-A|[-]*[0-9]+A|\-|[0-9]+"/>
</operator>
<operator name="Replace A with 1" class="Replace">
<parameter key="attributes" value=".*"/>
<parameter key="replace_what" value="A"/>
<parameter key="replace_by" value="1"/>
</operator>
<operator name="Add up the 1's" class="AttributeAggregation">
<parameter key="attribute_name" value="Count of %{Look_for}"/>
<parameter key="aggregation_attributes" value="att.*"/>
<parameter key="aggregation_function" value="count"/>
</operator>
<operator name="FeatureNameFilter" class="FeatureNameFilter">
<parameter key="skip_features_with_name" value="att.*"/>
</operator>
<operator name="IORetriever" class="IORetriever">
<parameter key="name" value="bla"/>
<parameter key="io_object" value="ExampleSet"/>
</operator>
<operator name="ExampleSetJoin" class="ExampleSetJoin">
<parameter key="remove_double_attributes" value="false"/>
</operator>
</operator>
PS Last edit I think covers most cases, also last version only worked on enterprise, as it used numerica2formattednominal, using numerica2polynominal seems to work OK.
0 -
That was interesting... Thanks
Shubha0