Options

Generate new Attributes with some calculations

Gopal_DesaiGopal_Desai Member Posts: 12 Contributor I
edited June 2020 in Help

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

  • Options
    lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 1,195 Unicorn
    edited June 2020 Solution Accepted
    Hi Gopal,

    You can use the Lag operator (with lag = 1) on the timestamp attribute.
    Please see the tutorial of this operator to understand how it works.
    Then use the date_diff() function in the Generate Attributes operator.


    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

Answers

  • Options
    rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 568 Unicorn
    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?
  • Options
    Gopal_DesaiGopal_Desai Member Posts: 12 Contributor 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

  • Options
    Gopal_DesaiGopal_Desai Member Posts: 12 Contributor 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 

  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,517 RM 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
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • Options
    rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 568 Unicorn
    Awesome, I didn't know about Group Into Collection.
  • Options
    Gopal_DesaiGopal_Desai Member Posts: 12 Contributor 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

  • Options
    lionelderkrikorlionelderkrikor Moderator, RapidMiner Certified Analyst, Member Posts: 1,195 Unicorn
    Hi @Gopal_Desai,

    You have first to install the Operator Toolbox extension from the marketplace.

    Regards,

    Lionel
Sign In or Register to comment.