RapidMiner

RM Certified Expert
RM Certified Expert

Re: Classification by regression with text in input

@evelyne_tran_1 Or if you want to do clustering, why do you need a label at all?  You could simply do one of the unsupervised clustering algorithms such as k-means that does not utilize a label.  It will create clusters based on the underlying data structure of your texts.  That sounds more like what you are interested in doing.  Otherwise as @Thomas_Ott says, you will need a separate label for a supervised algorithm like regression.

Brian T., Lindon Ventures - www.lindonventures.com
Analytics Consulting by Certified RapidMiner Analysts
Learner III evelyne_tran_1
Learner III

Re: Classification by regression with text in input

I have already done the clustering thanks to the k-means algorithm but I didn't get the expected results (the quality of my clusters were not good enough). I read an article about regression clustering saying that it was significantly different from the k-means algorithm and I wanted to try it for my study.

 

I just added another column in my data mentionned this time that the 2nd column was my label. I thinl that I have another issue now with the "Process document" operator saying : "Process failed. java.lan.double cannot be cast to java.lang.string"

Learner III evelyne_tran_1
Learner III

Re: Classification by regression with text in input

@Telcontar120@Thomas_Ott,

 

Any recommendation for this issue? How can I process only 1 column of my excel sheet but take into consideration 2 columns for the Verification/Classification by regression" operator ?

RM Certified Expert
RM Certified Expert

Re: Classification by regression with text in input

I am not familiar with the error message you reference--can you post the xml of the process and a data sample if you would like help diagnosing the problem?

Brian T., Lindon Ventures - www.lindonventures.com
Analytics Consulting by Certified RapidMiner Analysts
Learner III evelyne_tran_1
Learner III

Re: Classification by regression with text in input

@Telcontar120,

 

Thanks for the answer. You will find the XML file attached to this message. As for the data sample, I just have 1 column with text data and I added, following your advice concerning the label attribute, another column with random integer.

RM Certified Expert
RM Certified Expert

Re: Classification by regression with text in input

So a couple of things that was hanging up your process. Since I don't have your data, I can't really explain the problem but I can make a good guess here.

 

In order to do classification on text processed data, you need to have a label column. I see that you only had a text column and then added in a Risk # as the label. That's the right thing to do because without the label, the model can't figure out what to predict into what class (i.e. yes or no, 0 or 1, etc). If you want to do classificaiton using regression you'll need to convert the Risk #'s to a nominal value. In the example below I just discretized them into two bins.

 

I also noticed that you're using a Data to Documents and generic Process Documents operator, it was giving some errors on the conversion part, so I swapped it out to just a Process Documents from Data operator. I also added some pruning in my example and it all works fine now. 

 

Your next step is to take your XLS file and connect that into the Process Documents from Data operator. You might need to bring the data with no formats (i.e. not as a label and text) and then add Nom to Text operator and  Set Role operator right before you feed it into the Process Documents from Data operator. 

 

 

<?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.4.000" expanded="true" name="Process">
    <parameter key="encoding" value="SYSTEM"/>
    <process expanded="true">
      <operator activated="false" class="read_excel" compatibility="7.4.000" expanded="true" height="68" name="Read Excel" width="90" x="313" y="34">
        <parameter key="excel_file" value="C:\Users\Evelyne\Desktop\Projet de recherche - Bombardier Aerospace\09. RapidMiner\Test\Test 4 (Risk description with small changes)\Test données.xlsx"/>
        <parameter key="imported_cell_range" value="A1:B11"/>
        <parameter key="encoding" value="SYSTEM"/>
        <parameter key="first_row_as_names" value="false"/>
        <list key="annotations">
          <parameter key="0" value="Name"/>
        </list>
        <list key="data_set_meta_data_information">
          <parameter key="0" value="Risk description.true.text.attribute"/>
          <parameter key="1" value="# risk.true.integer.label"/>
        </list>
      </operator>
      <operator activated="true" class="social_media:search_twitter" compatibility="7.3.000" expanded="true" height="68" name="Search Twitter" width="90" x="45" y="136">
        <parameter key="connection" value="NewConnection"/>
        <parameter key="query" value="RapidMiner"/>
        <parameter key="language" value="en"/>
      </operator>
      <operator activated="true" class="select_attributes" compatibility="7.4.000" expanded="true" height="82" name="Select Attributes" width="90" x="179" y="136">
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attributes" value="Retweet-Count|Text"/>
      </operator>
      <operator activated="true" class="nominal_to_text" compatibility="7.4.000" expanded="true" height="82" name="Nominal to Text" width="90" x="313" y="136">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="Text"/>
      </operator>
      <operator activated="true" class="discretize_by_bins" compatibility="7.4.000" expanded="true" height="103" name="Discretize" width="90" x="447" y="136">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="Retweet-Count"/>
        <parameter key="number_of_bins" value="3"/>
      </operator>
      <operator activated="true" class="set_role" compatibility="7.4.000" expanded="true" height="82" name="Set Role" width="90" x="648" y="187">
        <parameter key="attribute_name" value="Retweet-Count"/>
        <parameter key="target_role" value="label"/>
        <list key="set_additional_roles"/>
      </operator>
      <operator activated="true" class="text:process_document_from_data" compatibility="7.4.001" expanded="true" height="82" name="Process Documents from Data" width="90" x="648" y="34">
        <parameter key="prune_method" value="percentual"/>
        <list key="specify_weights"/>
        <process expanded="true">
          <operator activated="true" class="text:tokenize" compatibility="7.4.001" expanded="true" height="68" name="Tokenize" width="90" x="45" y="34"/>
          <operator activated="true" class="text:filter_stopwords_english" compatibility="7.4.001" expanded="true" height="68" name="Filter Stopwords (English)" width="90" x="179" y="34"/>
          <operator activated="true" class="text:filter_by_length" compatibility="7.4.001" expanded="true" height="68" name="Filter Tokens (by Length)" width="90" x="313" y="34">
            <parameter key="min_chars" value="2"/>
          </operator>
          <operator activated="true" class="text:stem_porter" compatibility="7.4.001" expanded="true" height="68" name="Stem (Porter)" width="90" x="447" y="34"/>
          <operator activated="true" class="text:transform_cases" compatibility="7.4.001" expanded="true" height="68" name="Transform Cases" width="90" x="581" y="34"/>
          <connect from_port="document" to_op="Tokenize" to_port="document"/>
          <connect from_op="Tokenize" from_port="document" to_op="Filter Stopwords (English)" to_port="document"/>
          <connect from_op="Filter Stopwords (English)" from_port="document" to_op="Filter Tokens (by Length)" to_port="document"/>
          <connect from_op="Filter Tokens (by Length)" from_port="document" to_op="Stem (Porter)" to_port="document"/>
          <connect from_op="Stem (Porter)" from_port="document" to_op="Transform Cases" to_port="document"/>
          <connect from_op="Transform Cases" 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>
      <operator activated="true" class="split_validation" compatibility="7.4.000" expanded="true" height="124" name="Validation" width="90" x="782" y="34">
        <parameter key="sampling_type" value="automatic"/>
        <process expanded="true">
          <operator activated="true" class="classification_by_regression" compatibility="7.4.000" expanded="true" height="82" name="Classification by Regression" width="90" x="179" y="34">
            <process expanded="true">
              <operator activated="true" class="linear_regression" compatibility="7.4.000" expanded="true" height="103" name="Linear Regression" width="90" x="246" y="34"/>
              <connect from_port="training set" to_op="Linear Regression" to_port="training set"/>
              <connect from_op="Linear Regression" from_port="model" to_port="model"/>
              <portSpacing port="source_training set" spacing="0"/>
              <portSpacing port="sink_model" spacing="0"/>
            </process>
          </operator>
          <connect from_port="training" to_op="Classification by Regression" to_port="training set"/>
          <connect from_op="Classification by Regression" from_port="model" to_port="model"/>
          <portSpacing port="source_training" spacing="0"/>
          <portSpacing port="sink_model" spacing="0"/>
          <portSpacing port="sink_through 1" spacing="0"/>
        </process>
        <process expanded="true">
          <operator activated="true" class="apply_model" compatibility="7.4.000" expanded="true" height="82" name="Apply Model" width="90" x="45" y="34">
            <list key="application_parameters"/>
          </operator>
          <operator activated="true" class="performance_classification" compatibility="7.4.000" expanded="true" height="82" name="Performance" width="90" x="179" y="34">
            <list key="class_weights"/>
          </operator>
          <connect from_port="model" to_op="Apply Model" to_port="model"/>
          <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
          <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
          <connect from_op="Performance" from_port="performance" to_port="averagable 1"/>
          <portSpacing port="source_model" spacing="0"/>
          <portSpacing port="source_test set" spacing="0"/>
          <portSpacing port="source_through 1" spacing="0"/>
          <portSpacing port="sink_averagable 1" spacing="0"/>
          <portSpacing port="sink_averagable 2" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="write_excel" compatibility="7.4.000" expanded="true" height="82" name="Write Excel" width="90" x="849" y="187">
        <parameter key="excel_file" value="C:\Users\Evelyne\Desktop\Projet de recherche - Bombardier Aerospace\09. RapidMiner\Résultat.xlsx"/>
        <parameter key="encoding" value="SYSTEM"/>
      </operator>
      <connect from_op="Search Twitter" from_port="output" to_op="Select Attributes" to_port="example set input"/>
      <connect from_op="Select Attributes" from_port="example set output" to_op="Nominal to Text" to_port="example set input"/>
      <connect from_op="Nominal to Text" from_port="example set output" to_op="Discretize" to_port="example set input"/>
      <connect from_op="Discretize" from_port="example set output" to_op="Set Role" to_port="example set input"/>
      <connect from_op="Set Role" from_port="example set output" to_op="Process Documents from Data" to_port="example set"/>
      <connect from_op="Process Documents from Data" from_port="example set" to_op="Validation" to_port="training"/>
      <connect from_op="Validation" from_port="model" to_port="result 1"/>
      <connect from_op="Validation" from_port="training" to_op="Write Excel" to_port="input"/>
      <connect from_op="Validation" from_port="averagable 1" to_port="result 2"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
      <portSpacing port="sink_result 3" spacing="0"/>
    </process>
  </operator>
</process>
Polls
How can RapidMiner increase participation in our new competitions?
Twitter Feed