Options

Feature Request....Filter example range....select last x records

hughesfleming68hughesfleming68 Member Posts: 323 Unicorn
edited June 2019 in Help
This is one operator that I use all the time. It is especially handy to chop off the beginning of a data set by selecting record 1 -> x and hitting invert. It is on the other hand much more involved to do from the other end of the data set. It can be done in python in one line. df = df.tail(x). Unless I have missed something all these years, I have been counting records and then building macros to create a window for the last x records. Can we have an easier/faster way to do this? I know you can sort, apply the filter and sort back but the filter example range operator should be able to work on both ends of the dataset.

regards,

Alex
Tagged:

Best Answer

  • Options
    hughesfleming68hughesfleming68 Member Posts: 323 Unicorn
    edited May 2019 Solution Accepted
    Hi Janito, you need to break the problem down into pieces. The following process will do what you want. When you construct a process like this, you need to be careful of the order of the operators. Make sure that your macros are set first before you do any filtering. Let me know if this solves your problem.

    regards,

    Alex

    Edit....I uploaded a correction. There was one extra operator that was not needed. Both rmp files should work. The smaller one is the correct one.

Answers

  • Options
    kypexinkypexin Moderator, RapidMiner Certified Analyst, Member Posts: 291 Unicorn
    Hi Alex, 

    One pretty fast workaround to do that might be using EXTRACT MACRO operator and generate macro of type "number_of_examples" which then can be used in FILTER EXAMPLE RANGE operator. 


  • Options
    hughesfleming68hughesfleming68 Member Posts: 323 Unicorn
    edited April 2019
    Thanks kypexin. That is how I do it now using macros. I am suggesting that it should be part of the filter example range operator and as simple as it is to do in python. I agree, your suggestion is the best way to it.
  • Options
    JanitoJanito Member Posts: 9 Contributor II
    Thanks kypexin. That is how I do it now using macros. I am suggesting that it should be part of the filter example range operator and as simple as it is to do in python. I agree, your suggestion is the best way to it.

    Hey Alex,

    can you please show me an example? Iam currently stucked with this problem.
    I want to erase the last examples of my database which doesnt contain a specific value. I tried to generate two macros and use filter range, but the number of rows is different in every of my tables.

    Attached you will find my sample data.

    Now I want to erase every example after my example value "D". I tought about using a "if then else" cause, but iam pretty new to RapidMiner and it isnt working well.
    Maybe somebody can help me please?`

    Greetings
    Janito





  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,524 RM Data Scientist
    Hi @Janito
    i think you want to use the Filter Examples operator and filter for id > 9.
    Best,
    Martin
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • Options
    JanitoJanito Member Posts: 9 Contributor II
    Hey Martin,

    thank you for your response! My input data will be different every time, so next time the value "D" might be in the place of ID 8 or 5. Thats why I was looking for a way to use "if then else" to determine the last value "D" in my data and cut the rest below from my list.
  • Options
    JanitoJanito Member Posts: 9 Contributor II
    Hey Alex,

    thank you for your answer! You helped me to solve this problem.

    Have a nice day.

    Greets
    Janito
Sign In or Register to comment.