Orange Forum • View topic - How do I properly concatenate an Orange Table.

How do I properly concatenate an Orange Table.

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

How do I properly concatenate an Orange Table.

Postby quijibo » Sat Dec 14, 2013 17:23

I have two data sets that I have to parse seperately and concatenate together. I wrote a script to do this...


Code: Select all
import numpy as np
import Orange

y_vals = [ float(in_data[i]['y-value']) for i in range(0,len(in_data)) ]
x_vals = [ float(in_data[i]['x-value']) for i in range(0,len(in_data)) ]

m,b = np.lib.polyfit(x_vals, y_vals, 1)
fitted = [m*x+b for x in x_vals]

ave = np.mean(y_vals)
adj_y_vals = [ave + actual - expected for actual, expected in zip(y_vals,fitted)]

# construct a new orange table with an additional column containing
# the adjusted y values
new_feature = Orange.feature.Continuous('norm_y-values')
new_domain = Orange.data.Domain([new_feature]+[feature for feature in in_data.domain])
new_data = [[adj_y_vals[i]] + x.native(0) for i,x in enumerate(in_data) ]

out_data = Orange.data.Table(new_domain, new_data)


I run the script on the two data sets using the script widget and it parses them perfectly. When I link the outputs from the script widgets to the concatenate widget I lose the data for one of the sets. Why does this happen? Is it a problem with how I've created the new data table? I'm new to Orange so any help would be appreciated.

Also, I should mention that this is just a very simple example or a very small part of a larger project I'm doing. My data won't be seperated into individual files like this and I'll have many different data sets to deal with. Writing a script to parse the individual components and concatenate them is the best way for me to accomplish my end goal.

Re: How do I properly concatenate an Orange Table.

Postby Ales » Mon Dec 16, 2013 11:43

quijibo wrote: When I link the outputs from the script widgets to the concatenate widget I lose the data for one of the sets. Why does this happen? Is it a problem with how I've created the new data table?
This is a problem with how you create the new feature. In Orange all features created through their respected constructors (Orange.feature.Continuous, Orange.feature.Discrete, ...) are distinct from each other (see reuse-of-descriptors for details and reasoning behind this).

To fix this use the 'make' class method to construct (reuse) a new feature.

Code: Select all
new_feature, status = Orange.feature.Descriptor.make('norm_y-values',  Orange.feature.Type.Continuous)


Return to Questions & Support