Orange Forum • View topic - How to assign a Class Label in different paths

How to assign a Class Label in different paths

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

How to assign a Class Label in different paths

Postby bricklemacho » Tue Feb 12, 2013 4:18

Hi, I back playing with Orange. I want to process images, produce a feature vector and then use the feature vector within orange. Initially I will write some widgets and use the orange canvas.

As a simple proof of concept I have a widget that loads a set of images, a basic widget to calculates some statistics on the image stream and outputs a Orange Table. Each row representing the statistical description of an image. I have one path that process +ve exemplars, another path that process -ve exemplars. The "statistics" widget assigns a class label through a an input text box. I concatenate the output form both paths, via the concatenate widget, into a single table.

It appears that the class label is not recognised/used as a class label. See the code below where I create the Orange Table. I assign the Label as type "string". From inspection of some of the example data file (iris.tab etc) I believe this label needs to be "discrete". I can change it to Orange.feature.Type.Discrete, but it does not seem to like the "string" value returned. I can save the output form the concatenation widget, manually edit the file and change "String" to "Discrete", load the edited file and class labels are ok. How or is there a way I can assign a class label on each path to later be recognised as a class label later in the path/process.

I have had a look at the paint data widget where it appears to enumerate the values (as well as providing a way to add new class values), but this widget "knows" all possible values when it enumerates, where as I have separate paths and was hoping to be able to dynamically assign class label on each path depending on what object classifier I am building (hope that makes sense). Or must my statistics widget "know" all possible enumerations/classes and have the user pick one form a list?


Code: Select all
# Create/reuse 'mean', 'variance' and 'skew' feature descriptors.
descriptors_and_status = [Orange.feature.Descriptor.make(x, Orange.feature.Type.Continuous)
      for x in ['mean', 'variance', 'skew', 'kurtosis', 'energy', 'entropy']]
# Get rid of status codes from the 'make' calls.
descriptors = [pair[0] for pair in descriptors_and_status]
# Reuse the 'Label' descriptor
descriptors.append(Orange.feature.Descriptor.make('Label', Orange.feature.Type.String)[0])
domain = Orange.data.Domain(descriptors)
self.data = Orange.data.Table(domain,feature_vector)

Re: How to assign a Class Label in different paths

Postby Ales » Tue Feb 12, 2013 13:32

bricklemacho wrote: Or must my statistics widget "know" all possible enumerations/classes and have the user pick one form a list?
This would be best, but I'm guessing you don't have a known list (uses can add arbitrary text labels?).

I don't think there is a clean solution for this. You might keep the labels in a String feature and then convert it into a discrete feature in a new dedicated widget (maybe even add something like this to 'Edit Domain' widget).

Re: How to assign a Class Label in different paths

Postby bricklemacho » Tue Feb 12, 2013 19:08

Thanks. You are correct in assuming I want the users to be able to add arbitrary labels during the creation of the image descriptors.

I am probably extend/using Orange in way not originally intended. I could process the images off line and import a file contain the feature vectors it feel nice to be able to visually explore the creation of the feature vectors within Orange and then explore the feature vector space.

I have a demo to give so for now I will restrict the class labels. I will investigate keeping labels as a string and either creating a dedicated widget or perhaps extend 'Edit Domain' widget at a later stage.

Thanks again.


Return to Questions & Support