Search code examples
data-miningtext-miningrapidminer

How to reduce text dimensions in RapidMiner


I am having a challenge with using Rapid Miner to reduce the feature dimensions for text mining. at this point i am processing the text by word tokens and it is resulting in a very big dimension set that is not ideal for modeling and prediction. how can i improve the process to use other methods to clean the data and only take on relevant words?

i have tried applying tfidf but it removes the target variable and i am not able to see what it does before the model stage.

Thanks


Solution

  • The Process Documents operator has a pruning option where, with some careful setting of parameters, you can remove common and rare attributes.

    Here's a toy example to show it working.

    <?xml version="1.0" encoding="UTF-8"?><process version="7.5.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="7.5.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="text:create_document" compatibility="7.4.001" expanded="true" height="68" name="Create Document" width="90" x="179" y="187">
            <parameter key="text" value="the cat sat on the mat&#10;the dog barked at the man&#10;the cow ate the grass&#10;the man sat on the grass"/>
          </operator>
          <operator activated="true" class="text:create_document" compatibility="7.4.001" expanded="true" height="68" name="Create Document (2)" width="90" x="179" y="289">
            <parameter key="text" value="the cat sat on the mat&#10;the man sat on the grass&#10;the rain in spain falls mainly on the plain"/>
          </operator>
          <operator activated="true" class="text:create_document" compatibility="7.4.001" expanded="true" height="68" name="Create Document (3)" width="90" x="179" y="391">
            <parameter key="text" value="the world is round"/>
          </operator>
          <operator activated="true" class="text:process_documents" compatibility="7.4.001" expanded="true" height="145" name="Process Documents" width="90" x="447" y="187">
            <parameter key="vector_creation" value="Term Occurrences"/>
            <parameter key="prune_method" value="absolute"/>
            <parameter key="prune_above_percent" value="40.0"/>
            <parameter key="prune_below_absolute" value="2"/>
            <parameter key="prune_above_absolute" value="5"/>
            <process expanded="true">
              <operator activated="true" class="text:tokenize" compatibility="7.4.001" expanded="true" height="68" name="Tokenize" width="90" x="246" y="34"/>
              <connect from_port="document" to_op="Tokenize" to_port="document"/>
              <connect from_op="Tokenize" from_port="document" to_port="document 1"/>
              <portSpacing port="source_document" spacing="0"/>
              <portSpacing port="sink_document 1" spacing="0"/>
              <portSpacing port="sink_document 2" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Create Document" from_port="output" to_op="Process Documents" to_port="documents 1"/>
          <connect from_op="Create Document (2)" from_port="output" to_op="Process Documents" to_port="documents 2"/>
          <connect from_op="Create Document (3)" from_port="output" to_op="Process Documents" to_port="documents 3"/>
          <connect from_op="Process Documents" from_port="example set" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    

    It requires some care to get it just right but hopefully this will get you started.