0
$\begingroup$

I Have a general question - how to preprocess data in Orange. E.g. I want to do something with each row value of some feature. How can I do this visually? And how can I do this via Python Script?

So far, I have only some ideas how to do this via python script:

Here is my code:

minimum = min(list(map(lambda row: row[0], in_data))).value

from copy import deepcopy
out_data = deepcopy(in_data)

for row in out_data:
    row[0].value = row[0].value - minimum

But it fails, because seems like the Value object is immutable... Is there any way to create my own Value object with new data, and then do something like:

out_data = list(map(lambda row: Value(row[0].variable, [row[0].value - minimum]) + row[1:], in_data))

I am also interested in a "Visual widget-based" alternative, if it exists...

$\endgroup$
2
$\begingroup$

To scale the data, you can use Preprocess widget. To construct new features, e.g.

new_feature = old_feature - some_values

you can use Feature Constructor widget.

$\endgroup$
  • $\begingroup$ Feature Constructor seems to match my needs, but how can I implement something like this: new_feature = old_feature - <min value of old feature>? $\endgroup$ – yashaka Aug 29 '16 at 23:24
  • $\begingroup$ I don't know. Whoever designed the widget didn't seem to account for this use case. The project seems pretty active, you should submit an enhancement request on their issue tracker: github.com/biolab/orange3 $\endgroup$ – K3---rnc Aug 30 '16 at 12:40
0
$\begingroup$

Something like this worked for my case:

minimum = min(list(map(lambda row: row[0].value, in_data)))

from copy import deepcopy
out_data = deepcopy(in_data)

import Orange
for i in range(len(out_data)):
    out_data[i,0] = Orange.data.Value(out_data[i,0].variable, out_data[i,0].value - minimum)

Interesting is that in order to plot the out_data, I needed additional "Select Columns" widget before "Scatter Plot".

In addition I couldn't combine two out_data (one from one source and one from another) on one Scatter Plot... But this seems to be an other question...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.