The Altair Community is migrating to a new platform to provide a better experience for you. The RapidMiner Community will merge with the Altair Community at the same time. In preparation for the migration, both communities are on read-only mode from July 15th - July 24th, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here.
Options

Using TensorFlow

nskpltanskplta Member Posts: 3 Contributor I
edited November 2018 in Help

Hi all, 

is there any way to integrate a TensorFlow script from Python into RapidMiner?

Also, is it possible to execute a complete Python file in the RapidMiner environment?

 

thanks a lot

Best Answer

  • Options
    Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn
    Solution Accepted

    You can execute Python via the Execute Python extension. So you can use Tensor via that extension.

     

    TensorFlow recently released an initial API for Java so you could develop your own extension for RapidMiner.

Answers

  • Options
    nskpltanskplta Member Posts: 3 Contributor I

    Thanks Thomas. I have seen the small Python scripts integrating into a RapidMiner process. However, is it possible to convert a whole Python project into RapidMiner "blocks", in order to take advantage of RapidMiner flexibility and powerful visualization tools?

     

    thanks again.

  • Options
    Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    Yes. We have quite a few customers that use Python and R inside RapidMiner Studio and Server. If you check out the Cappius webinar, they did just that. They took R scripts and some other scripts and put them all into RapidMiner to operationalize it. 

     

     

  • Options
    nageshkumarappnageshkumarapp Member Posts: 1 Contributor I

    ### An example of building a TensorFlow model from R using rPython ###
    # For this script you need to
    # 1. Have python 2.7 installed.
    # 2. Install the rPython package in R.
    # 3. Install Google's TensorFlow library as per these instructions:
    # http://www.tensorflow.org/get_started/os_setup.md#binary_installation

    ### Here is how to setup and run a trivial TensorFlow model ###

    # Load TensorFlow (I couldn't get this to work without setting sys.argv... )
    library(rPython)
    python.exec("
    import sys
    sys.argv = ['']
    import tensorflow as tf
    ")

    # Define a "hello world" TensorFlow model adding two numbers
    python.exec("
    a = tf.constant(10)
    b = tf.constant(32)
    sum = a + b
    ")

    #Instantiate a TensorFlow session, and get the result into R.
    # (we need the .tolist() to convert from the result into something
    # that can be serialized by JSON and imported into R)
    python.exec("
    sess = tf.Session()
    result = sess.run(sum)
    ")
    result = python.get("result.tolist()")

    # Tada! :)
    print(result)
    ## [1] 42

     

    Thank You 

    Nagesh Kumar

  • Options
    vivek101vivek101 Member Posts: 8 Contributor II
    Hi,

    Using the Python Scripting extension, TensorFlow programs written in Python may be imported into RapidMiner. TensorFlow scripts may be created and run using the Python Script operator in the RapidMiner environment, whilst Python files can be run using the Execute Script operator.

    Following these steps:

    1. Install the Python Scripting extension in RapidMiner.
    2. Create a new RapidMiner process.
    3. Add a Python Script operator to the process.
    4. In the Python Script operator, write your TensorFlow script using Python syntax. For example:
    import tensorflow as tf

    # Build a simple TensorFlow model
    model = tf.keras.Sequential([
        tf.keras.layers.Dense(64, activation='relu'),
        tf.keras.layers.Dense(1, activation='sigmoid')
    ])

    # Train the model on some data
    model.compile(optimizer='adam', loss='binary_crossentropy')
    model.fit(x_train, y_train, epochs=10)

    # Make predictions using the trained model
    predictions = model.predict(x_test)

    5. Run the RapidMiner process to execute the TensorFlow script.
    6. Use the output of the Python Script operator in subsequent RapidMiner operators to perform further data analysis or processing.

    By following these steps, you can easily integrate TensorFlow scripts from Python into your RapidMiner workflows.

    Thank you 
    Vivek Garg
    React Native
Sign In or Register to comment.