Options

Problem with Nominal to Date

blatooblatoo Member Posts: 32 Contributor II
edited November 2018 in Help
Hello RapidMiner Team,

I have a problem with the "Nominal to Date". I don't know, if it is a bugger.

I have a small table, with attribute "time" and "value", "time" is nominal, value is numerical

id     time         value
1 10:00:00 3.0
2 11:00:00 4.0
3 12:00:00 5.0
4 12:30:00 6.0
5 13:00:00 7.0
6 14:00:00 8.0

In my process, I apply the "Nominal to Date" on "time" attribute with the data format: hh:mm:ss, then I plot the result with "Scatter", x-Axis: time, y-Axis: value,
then I notice that, RapidMiner consider 12:00:00 equals 00:00:00, so it is much earlier than 10:00:00 !!! Why???

Thanks very much in advance!

Here is my process:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.2.000">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="6.2.000" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="retrieve" compatibility="6.2.000" expanded="true" height="60" name="Retrieve timeTest" width="90" x="179" y="345">
        <parameter key="repository_entry" value="//myLearningRepository/database/timeTest"/>
      </operator>
      <operator activated="true" class="nominal_to_date" compatibility="6.2.000" expanded="true" height="76" name="Nominal to Date" width="90" x="313" y="345">
        <parameter key="attribute_name" value="time"/>
        <parameter key="date_type" value="time"/>
        <parameter key="date_format" value="hh:mm:ss"/>
      </operator>
      <connect from_op="Retrieve timeTest" from_port="output" to_op="Nominal to Date" to_port="example set input"/>
      <connect from_op="Nominal to Date" from_port="example set output" 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>



Here is my plotted picture

image








Answers

  • Options
    awchisholmawchisholm RapidMiner Certified Expert, Member Posts: 458 Unicorn
    Hello

    Try changing the date string to "HH:mm:ss" - the upper case HH signifies 24 hour format

    Andrew
  • Options
    blatooblatoo Member Posts: 32 Contributor II
    Hi Andrew,

    thanks very much for the tip! It works!!!

    by the way, I bought your book "Exploring Data with RapidMiner" from amazon and read it completely in last days, it is so good and practical orientated! Thanks very much!

    Conny
  • Options
    awchisholmawchisholm RapidMiner Certified Expert, Member Posts: 458 Unicorn
    Hello Conny

    Glad to help ):

    Andrew
  • Options
    DocMusherDocMusher Member Posts: 333 Unicorn
    Hi RM's
    I have a similar problem. But my time data ranges from 00:00 to 200:00, which means duration expressed in hours:minutes. The type is guessed as polynomial. how can I change this duration to data I can use for calculation?
    Cheers
    Sven
  • Options
    awchisholmawchisholm RapidMiner Certified Expert, Member Posts: 458 Unicorn
    Hello

    You could use the "Generate Extract" operator like so to convert hours and minutes in the format "hours:minutes" where hours can be greater than 23.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.2.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.2.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data_user_specification" compatibility="6.2.000" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="112" y="75">
            <list key="attribute_values">
              <parameter key="duration" value="&quot;201:21&quot;"/>
            </list>
            <list key="set_additional_roles"/>
          </operator>
          <operator activated="true" class="text:generate_extract" compatibility="6.1.000" expanded="true" height="60" name="Generate Extract" width="90" x="246" y="75">
            <parameter key="source_attribute" value="duration"/>
            <parameter key="query_type" value="Regular Expression"/>
            <list key="string_machting_queries"/>
            <parameter key="attribute_type" value="Numerical"/>
            <list key="regular_expression_queries">
              <parameter key="hours" value="(\d+):.*"/>
              <parameter key="minutes" value="\d+:(\d+)"/>
            </list>
            <list key="regular_region_queries"/>
            <list key="xpath_queries"/>
            <list key="namespaces"/>
            <list key="index_queries"/>
            <list key="jsonpath_queries"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="6.2.000" expanded="true" height="76" name="Generate Attributes" width="90" x="380" y="75">
            <list key="function_descriptions">
              <parameter key="newduration" value="hours*60+minutes"/>
            </list>
          </operator>
          <connect from_op="Generate Data by User Specification" from_port="output" to_op="Generate Extract" to_port="Example Set"/>
          <connect from_op="Generate Extract" from_port="Example Set" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" 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>
    regards

    Andrew
Sign In or Register to comment.