Orange Forum • View topic - Deriving new field

Deriving new field

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

Deriving new field

Postby danielFH » Tue May 13, 2008 12:03

Hi there,

i just wanted to ask, whether it is possible to derive a new field from 2 or more other fields, e.g. Speed=Length/time. I can't find a mathematics or deriving function in Orange.

Thanks for your answers,

Daniel

FH Stralsund

Postby Mirco » Thu May 15, 2008 9:32

Hello Daniel,

i'm looking for this function, too, but i didn't find a possibility to derive a field with mathematics.

greetz

Mirco

Postby Janez » Thu May 15, 2008 11:57

You want to do it in Canvas or in a script?

In canvas there is a widget Feature Constructor in the Prototypes tab which does that. If you don't have it, you can download it from the SVN and put it somewhere, e.g. to orangeWidgets/Data and rebuild the widget registry, so it will appear in the Data toolbar.

If you want to do it in a script, see section "Using getValueFrom" in http://www.ailab.si/orange/doc/reference/Variable.htm. See, for instance, http://www.ailab.si/orange/doc/reference/variable2.py.

Janez

Postby danielFH » Thu Jun 12, 2008 8:54

HI,

thanks for your answer. It worked with the latest nightly build.

But my next question is: is it possible to calculate the new value based on conditions? Such as:

New Field: Wants_Car
Formula: if (gender=='m'): Wants_Car=1
else: Wants_Car=0

(Pseudo-Code just for explanation!)

And again, i want to do this in the GUI, not with scripting python code!

Is that possible?

Thanks in advance!
With kind regards,

Daniel K.

Postby sapienza » Wed Sep 03, 2008 11:33

Hi all,

i was wondering how this widget you are talking about have to be used. I need to build a new feature from an existing one, and i woule like to make the new one in a logarithmic scale. What do i have to insert in "expression" field? I tried with

PSINORM := LOG ( PERCENTUALE SI)

but it doesn't work.

Thanks for the help

Error message

Postby sapienza » Wed Sep 03, 2008 11:39

It always give me this error, whatever i write in field "expression":

Unhandled exception of type IndexError occured at 12:38:10:
Traceback:
File: orngSignalManager.py, line 61 in __call__
Code: self.method(*k)
File: OWGUI.py, line 1310 in __call__
Code: self.f(**kwds)
File: OWFeatureConstructor.py, line 171 in selectAttr
Code: selected = self.selectedDef[0]
IndexError: list index out of range

don't know if it's a bug or my fault


Return to Questions & Support