RapidMiner 9.7 is Now Available

Lots of amazing new improvements including true version control! Learn more about what's new here.


Use ta-lib library for data minig by Execute Script (groovy)

ikarusumaikarusuma Member Posts: 5 Contributor I
edited November 2018 in Help


I see the tutorial of Execute Script, that substract the mean of multiple attributes. And I would like to make something samed, data mining from technicial indicators.

First, I have a financial database which describe serial temporally  prices of an instrument of FOREX with the date and five attributes more (O,H, L, C and V). I can read it with rne Read CSV operator.

Second, I have a ta-lib-0.4.0.jar (C:\Program Files\RapidMiner\RapidMiner5\lib\ta-lib-0.4.0.jar) which is an open source and contains a large of technical financial indicators, like RSI, ADX, ...I downloaded it from http://ta-lib.org/hdr_dw.html

I would like to generate multiples attributes, with the name of theese indicators, and the values of them.

Is it possible? How can I do it?

Finally, if it is possible, I would like to do a loop parameters of the some parameters of theese indicators (period, ...)

I am acquantied with RM (blocks) but I don´t know anything about programming groovy. In some posts I read people who ask about how generate multiple attributes and how call a library .jar with the Execute Script but I can´t read some of them, because some links of topics are broken (http://rapid-i.com/rapidforum/index.php/topic,2214.msg8755.html#msg8755)

I have seen this interesting post (Data mining and technicial indicators) but it don´t say haw to do this.

Can anyone help me?



PS: Excuse me for my English.


Best Answer

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 465   Unicorn
    Solution Accepted

    Hi Ikarus!


    You would probably import like this:


    import com.tictactec.ta.lib.*

    In my experience, it was a good idea to develop the script step by step. First, just the import - if it is executed, fine. Then one function call without creating a new attribute, so you know the syntax works. Then creating the attribute etc.

    You could also download the Groovy software itself and experiment in the original environment. This might give you more insight or more detailed messages than Execute Script in RapidMiner does.


    When you look at the later examples like distance calculation, you'll see how a new attribute is created for returning the result of the function call.

    On the page of your library I've seen a function list, and there's also an XML file with the required parameters of the functions. You probably won't need every function. 




  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 465   Unicorn



    try these blog articles for topics like using an additional library with RapidMiner and calling functions from Groovy:



    Good luck!



  • ikarusumaikarusuma Member Posts: 5 Contributor I

    Thanks Balázs!

    Yesterday, I read your articles. It was very interesting for me because I worked with ArcGis software for 5 years. I think I understand the process parts to do it but there are many things I don´t understand still.

    Now I have a few doubts...

    1_First, I have to call Ta-lib library installed en /lib, I think in this way, isn't it?

    import com.rapidminer.example.*;
    import com.rapidminer.example.table .*;
    import com.rapidminer.example.set .*;
    import com.rapidminer.tools .Ontology;
    import java.util.*;
    import com.tictactec.ta.lib

    2_Next, I have to create a multiples attributes (RSI, ADX,...) with the names of the Ta-lib classes. But how can I put the name of the class directly of the ta-lib? Should I rename all classes with a new names like this example code (I don´t need any label)? For do this I should know all the names classes in the TA-lib library... I thought Script might make it directly...In your tutorial-part_2, when you call your shapefile, you add all his fields and values, but this a file no a library. I think I don´t need this part because I´ve already the csv file with the attributes (date, open, high, low,close) that are used for calculating the TA-lib indicators. That is my confussion.

    public class CreatingExampleTables {
    public static void main(String [] argv) {
    // create attribute list
    List <Attribute> attributes = new LinkedList<Attribute>();
    for ( int a = 0; a < getMyNumOfAttributes(); a++) {
    attributes.add( AttributeFactory . createAttribute (”att” + a,
    //Attribute label = AttributeFactory . createAttribute (” label ”, Ontology.NOMINAL));
    //create table
    MemoryExampleTable table = new MemoryExampleTable(attributes);
    // fill table (here : only real values )
    for (int d = 0; d < getMyNumOfDataRows(); d++) {
    double[] data = new double[attributes.size()];
    for (int a = 0; a < getMyNumOfAttributes(); a++) {
    //fill with proper data here
    data = getMyValue(d, a);
    // maps the nominal classification to a double value
    data[data.length -...

    AssociationRules rules = input[0];

    // construct attribute set
    Attribute[] attributes= new Attribute[11];
    attributes[0] = AttributeFactory.createAttribute("Premise", Ontology.STRING);

    attributes[1] = AttributeFactory.createAttribute("Premise Items", Ontology.INTEGER);
    attributes[2] = AttributeFactory.createAttribute("Conclusion", Ontology.STRING);
    attributes[3] = AttributeFactory.createAttribute("Conclusion Items", Ontology.INTEGER);
    attributes[4] = AttributeFactory.createAttribute("Confidence", Ontology.REAL);
    attributes[5] = AttributeFactory.createAttribute("Conviction", Ontology.REAL);
    attributes[6] = AttributeFactory.createAttribute("Gain", Ontology.REAL);
    attributes[7] = AttributeFactory.createAttribute("Laplace", Ontology.REAL);

    attributes[8] = AttributeFactory.createAttribute("Lift", Ontology.REAL);
    attributes[9] = AttributeFactory.createAttribute("Ps", Ontology.REAL);

    attributes[10] = AttributeFactory.createAttribute("Total Support", Ontology.REAL);

    3_Finally, I need to calculate indicators values. For do this, in your example, you call GeodesicCalculator class from GeoTools library. In my case, would I need to call the indicators classes one by one? How can I know all the classes of my library? I opened source.code but I don´t understand it.

    An other thing is the parameters of theese classes. I would like to know how can I put the parameters of theese indicators. I have to put them into the code or I can get a list of them in a macro? Could I loop them into the code with a for or with an apply loop (like say in the point 5.9 How-to-Extend-RapidMiner-5.pdf)


    Well, now I I think there are a lot of questions in my topic. Perhaps it was interesting for the Rapidminer people to make a video tutorial of the Execute Script Operator and how import a library and get the classes of them for calculate the values of their functions. It´s only an idea:smileywink:

    While, I´m going to study more about groovy code. I think Execute Script could be a good tool for me, but it isn´t easy.


    Thank you very much Balázs for your time.

    Best regards,




Sign In or Register to comment.