Orange Forum • View topic - Using Python Script widget in Orange Canvas

Using Python Script widget in Orange Canvas

A place to ask questions about methods in Orange and how they are used and other general support.

Using Python Script widget in Orange Canvas

Postby vanorange » Wed Oct 03, 2012 8:36

Hi all,

I have started using Orange Canvas for performing a clustering technique to my data set. To suit it to my needs, I am using "Python Script" widget (i take input from the k-means widget and i perform my required analysis using "Python Script" widget). I have a few questions on using this "python script" widget.
a) Can I send two inputs to this "Python Script" widget (for e.g, my k-means widget returns both the cluster centres and my data set appended with their clusters. I want both of this data to be accessed in the python script widget). The connection of widgets I want is something like this :
k-means --> python script (python script widget should be able to take both the information)
If it is not possible to send two inputs simultaneously into a python script widget, is there any other alternative way to perform this?
b) How to send an output from "Python Script" widget to some other widget in orange canvas. (by simply connecting python script widget to another widget (say data table), I am not able to see the output/results from python script widget in the data table widget).

Thanks in advance.

Re: Using Python Script widget in Orange Canvas

Postby Ales » Wed Oct 03, 2012 10:33

vanorange wrote:Can I send two inputs to this "Python Script" widget (for e.g, my k-means widget returns both the cluster centres and my data set appended with their clusters. I want both of this data to be accessed in the python script widget)
No only one data set can be put into the widget at a time.
You could however store a reference to the first data set in the widget and then switch the inputs, i.e. execute
Code: Select all
centers = in_data
switch signals and then you have both centers and your data set with clusters (the new in_data).


vanorange wrote:How to send an output from "Python Script" widget to some other widget in orange canvas. (by simply connecting python script widget to another widget (say data table), I am not able to see the output/results from python script widget in the data table widget)

You assign to one of the output variables. For instance executing this script
Code: Select all
out_data = in_data
sends the input data unchanged.

Re: Using Python Script widget in Orange Canvas

Postby vanorange » Wed Oct 03, 2012 12:03

First of all, many thanks for giving a quick reply.

I understood the answer for the second question. But, I have a small doubt regarding the first question.
In the first answer, I presume that:
a) first, we have to store a reference of the data in the python script widget (this, we can do by assigning the input data to a variable; "centers=in_data will do this").
b) then, we have to switch the signals. (I guess we have to do this switching in the python script widget only).
So, can you tell me on how can we do the switching of signals in the python script widget. To explain more clearly: my k-means widget gives two outputs: a) Data (containing the appended clusters) b) Centroids (contains the cluster centres). When I connect my k-means widget and python script widget, a box will appear and asks for what signals have to be connected between these two widgets. After this, can you provide the information on how to switch this signal in python script widget.

I could not find any question on switching the signals in python script widget in the discussions/forums.

Many Thanks, again.

Re: Using Python Script widget in Orange Canvas

Postby Ales » Wed Oct 10, 2012 10:18

vanorange wrote:b) then, we have to switch the signals. (I guess we have to do this switching in the python script widget only).
So, can you tell me on how can we do the switching of signals in the python script widget.

No, I meant switch the signals in the canvas i.e. double click the connection between k-Means ad Python Script widget and switch Centroids -> in_data connection with Data -> in_data.

Re: Using Python Script widget in Orange Canvas

Postby vanorange » Thu Oct 11, 2012 8:07

Hi Ales,

Thanks, yeah, I got it now.
Earlier, I could not figure out that, after changing the signals in the connection, we have to comment the line where we have stored the reference to our earlier data set (so that we wouldnt be overwriting it again).


Return to Questions & Support



cron