Generate new Attributes with some calculations

Gopal_DesaiGopal_Desai MemberPosts:12Contributor I
edited June 2020 inHelp

Hello everyone,

I am new here and i don't have that much experience in Rapidminer. I have one Table in MySQL Database and i connected my Database with Rapidminer via MySQL. I get table from Database in Rapidminer like this. As you can see in Photo. Column 2, It shows Time when object comes on station. For example in First Row, Object 4B6B831A comes on station Arbeitsplatz1 at 04.03.20 13:49:29. When This Object leave the station(As you see in Row 2),It shows Wert=0 on station Arbeitsplatz1 at 04.03.20 13:49:41. Now I would like to add new Column (Process Time), It should Calculate time difference between 2nd Row and 1st Row. And it should show me in column(Process Time),

Same thing for ID(Column 1) 10 and 12. It should show me timestamp difference in new Column (Process Time).

I don't know how to calculate this thing every time, Whenever values has been added in Table. If anyone know could you please help me out.

Thank you in advance

Best Regards,

Gopal Desai

Best Answer

  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, MemberPosts:1,195Unicorn
    edited June 2020 Solution Accepted
    嗨Gopal,

    You can use theLagoperator (with lag = 1) on thetimestampattribute.
    Please see the tutorial of this operator to understand how it works.
    Then use thedate_diff()function in theGenerate Attributesoperator.


    EDIT :

    I misunderstood what you want to do. If I good understand, you want for each object calculate
    the duration between the arrival in Arbeitplatz-i and departure from arbeitplatz-i with i = 1,2,3 etc. ?
    I don't see a priori a RapidMiner native solution, maybe it is feasible with a Python script.



    Regards,

    Lionel
    Gopal_Desai

一个nswers

  • rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University ProfessorPosts:568Unicorn
    Hi@Gopal_Desai,

    Question: can there be two objects on a station at the same time, despite one entering first? Like...

    station 1: object AAAAAAAA, timestamp: 00:00
    station 1: object BBBBBBBB, timestamp: 00:02
    station 1: object 0, timestamp: 00:03

    If this happens, how to calculate this?
    Gopal_Desai
  • Gopal_DesaiGopal_Desai MemberPosts:12Contributor I
    edited June 2020

    Hi@rfuentealba

    Thank you so much for the reply. It is only one object at particular Station at the same Time. If one object leaves one Station then only other Object come on that station.

    Regards,

    Gopal

  • Gopal_DesaiGopal_Desai MemberPosts:12Contributor I
    edited June 2020

    lionelderkrikor

    Thank you so much for the reply. I think Lag Operator would be solution in my case. I filter whole Database according to Station. For example if Station = Arbeitsplatz1 then It shows me only value for Arbeitsplatz1. Then i used lag operator as you said before (Lag=1).

    but Problem is with Date_diff. If i use as Generate Attribute

    Process Time=date_diff(date_parse(timestamp),date_parse(timestamp-1))

    It Shows me error cannot create example set meta data:'_' must have arguments of type 'numerical'.

    i used date_parse because timestamp and timestamp-1 are string values.

    if you know, how to solve this problem, could you please help me out?

    Thank you in advance

    Best Regards,

    Gopal

  • MartinLiebigMartinLiebig 一个dministrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University ProfessorPosts:3,368RM Data Scientist
    you may want to use Group Into Collection to group per Arbeitsplatz and then do the Lag etc. in a Loop Collection. That avoids the 5 Filter Examples.
    Cheers,
    Martin
    - Head of Data Science Services at RapidMiner -
    Dortmund, Germany
    Gopal_Desai lionelderkrikor
  • rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University ProfessorPosts:568Unicorn
    一个wesome, I didn't know about Group Into Collection.
    Gopal_Desai
  • Gopal_DesaiGopal_Desai MemberPosts:12Contributor I

    mschmitz

    thank you so much for the Reply. I am not able to find Group into Collection. Where can i find Group into collection?

    Thank you

    Regards,

    Gopal

  • lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, MemberPosts:1,195Unicorn
    Hi@Gopal_Desai,

    You have first to install theOperator Toolboxextension from the marketplace.

    Regards,

    Lionel
Sign InorRegisterto comment.