The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Flatten an Exampleset
In the event that I had a dataset, say, that was 28x28. I want to take this 2D matrix and make it 1D with 784 attributes.
The obvious analogy here is the MNIST dataset in taking the 28x28 image to 1-row-per-image with the 784 features per image.
Admittedly I very rarely have the need to work with collections, and flows to assemble a dataset, but it's not jumping out to me as to how I can actually flatten an ExampleSet.
Context: With the image tools, we can a collection of length 3, one exampleset per color channel.
The obvious analogy here is the MNIST dataset in taking the 28x28 image to 1-row-per-image with the 784 features per image.
Admittedly I very rarely have the need to work with collections, and flows to assemble a dataset, but it's not jumping out to me as to how I can actually flatten an ExampleSet.
Context: With the image tools, we can a collection of length 3, one exampleset per color channel.
0
Best Answer
-
pschlunder Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, RMResearcher, Member Posts: 96 RM ResearchThanks for the details. Currently we don't have a reshape operator, also you can use "Execute Python Script" to call numpy's reshape.The process I've shared though, should flatten you any example set.You did not miss anything, right now there's no option to go from Tensor to ExampleSet, besides applying a model and getting the result than as an ExampleSet/Collection of ExampleSets. Both Tensor to ExampleSet and reshape are definetly operators we'd need to add in the future, as well as visualizations for Tensors.Please let me know if you have any problems with the flattening process provided.
0
Answers
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="9.8.001" expanded="true" name="Process">
<parameter key="logverbosity" value="init"/>
<parameter key="random_seed" value="2001"/>
<parameter key="send_mail" value="never"/>
<parameter key="notification_email" value=""/>
<parameter key="process_duration_for_mail" value="30"/>
<parameter key="encoding" value="SYSTEM"/>
<process expanded="true">
<operator activated="true" class="loop_examples" compatibility="9.8.001" expanded="true" height="103" name="Loop Examples" width="90" x="179" y="34">
<parameter key="iteration_macro" value="example"/>
<process expanded="true">
<operator activated="true" class="filter_example_range" compatibility="9.8.001" expanded="true" height="82" name="Filter Example Range" width="90" x="112" y="34">
<parameter key="first_example" value="%{example}"/>
<parameter key="last_example" value="%{example}"/>
<parameter key="invert_filter" value="false"/>
</operator>
<connect from_port="example set" to_op="Filter Example Range" to_port="example set input"/>
<connect from_op="Filter Example Range" from_port="example set output" to_port="output 1"/>
<portSpacing port="source_example set" spacing="0"/>
<portSpacing port="sink_example set" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<operator activated="true" class="operator_toolbox:merge" compatibility="2.9.000" expanded="true" height="82" name="Merge Attributes" width="90" x="380" y="34">
<parameter key="handling_of_duplicate_attributes" value="rename"/>
<parameter key="handling_of_special_attributes" value="keep_first_special_other_regular"/>
<parameter key="handling_of_duplicate_annotations" value="rename"/>
</operator>
<connect from_port="input 1" to_op="Loop Examples" to_port="example set"/>
<connect from_op="Loop Examples" from_port="output 1" to_op="Merge Attributes" to_port="example set 1"/>
<connect from_op="Merge Attributes" from_port="merged set" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>
And perhaps to ask my question differently. Is it possible to change the shape of ExampleSets. For example, we could take the 28x28 and make it a 1 x 784, or take that same 1x784 and reshape to 28x28? I am thinking about numpy.reshape.