Forum

Using Python in external scripts
Contributor
Offline
Posts: 38
Joined: Mon Jan 06, 2014 10:36 am

Kognitio and Python. Script Parameters

by skkirkham » Thu Jan 09, 2014 10:26 am

Hi all

Here is part 4 of series of topics to introduce Kognitio External Scripting using Python with accompanying examples

Part 1 to part 3 naturally follow on from each other. They form a good basis to get your python scripts up and running in a performant way. From here we start to introduce more general standalone topics. First of these is the need to pass parameters or generic data into each script invocation.

Two methods for passing genric parameters or data into scripts are given. The first utilises environment variables. This great if you have a series of single values you want to pass, such as answers from prompts in your BI reports or dashboards. The second example shows how to construct SQL statements that pass "global" data along with the main data set. This is useful if you need to send multiple rows of "global" data to each script. Ideally the "gobal" data has a similar format to the main data set and you need to be able to distinguish it from the raw data in your script.

Following on from previous posts simple averaging is used as an example but one analytical application where this is required is K-means clustering. When you carry out an iteration step you assign clusters to each row in the main data set. To do this you also need to know the values associated with the centroids of the clusters themselves. The centroid data has a similar format to the main data set so using SQL is a good option here. At some point in the furture we'll post an example of K-means clustering using external scripting to show how this works. If you have a go let me know how you get on.

Regards
Sharon

Note: the ability to receive multiple sets of data into a single script invocation is on the Kognitio product roadmap. When this is available you will be able to send any global data through one receives statement that is replicated to all script invocations while the main data set is passed through a second receives statement but that's for the future. Can't wait!
Reply with quote Top

Who is online

Users browsing this forum: No registered users and 1 guest

cron