Ticket #1185 (assigned bug)

Opened 2 years ago

Last modified 2 years ago

pick_class #RNGE bug

Reported by: mlevar Owned by: janez
Milestone: Future Component: library
Severity: minor Keywords: #RNGE, multi-target, pick_class
Cc: Blocking:
Blocked By:

Description

Sometimes when working with multi-target data and using the pick_class function the remaining classes get corrupted with values outside their range, represented by #RNGE.

This is a sample of code that reproduces the error. In the first one the error is minor and only produces two #RNGEs, the second example that also changes the domain to include the picked class into the features shows the escalation of the problem.

d = Orange.data.Table('bridges.v2.nm') for i in [3,2,1,0]:

i = random.randrange(0,3) print d.domain.class_vars[i] d.pick_class(d.domain.class_vars[i]) for x in d:

print x

d = Orange.data.Table('bridges.v2.nm') for i in [3,2,1,0]:

print d.domain.class_vars[i] d.pick_class(d.domain.class_vars[i]) for x in d:

print x

d.change_domain(Orange.data.Domain(d.domain, False, \

class_vars=d.domain.class_vars))

Attachments

bridges.v2.nm.tab Download (3.3 KB) - added by mlevar 2 years ago.
Dataset used in examples

Change History

Changed 2 years ago by mlevar

Dataset used in examples

comment:1 Changed 2 years ago by janez

  • Owner changed from janez to mlevar
  • Status changed from new to assigned

The code was unfortunately optimized for speed, not correctness. ;)

I fixed it, I guess. Please check again thoroughly if the attributes have correct values after pick_class. It would be great if somebody wrote unit tests that would cover all possible scenarios:

  • picking the first multiclass when the original domain already has a class
  • picking the first multiclass when the original domain already does not have a class
  • picking a non-first multiclass when the original domain already has a class
  • picking a non-first multiclass when the original domain already does not have a class

The tests would need to check whether the domain is constructed correctly and whether all attributes have correct values. Note that pick_class can change the order of class variables (that is, it is allowable to do so).

I'll reassign the ticket to Miran. Please write the test if you have time or reassign it back to me otherwise.

comment:2 Changed 2 years ago by mlevar

  • Owner changed from mlevar to janez
  • Keywords multi-target, pick_class added; multi-target removed
  • Severity changed from major to minor

Wrote the unittests (they are hardcoded for the multitarget-synthetic.tab file, but should do the job).

I discovered a new bug: selecting None with pick_class on a domain without a class_var adds None to the domain.

A test for this is written but is currently commented inside test_pick_class, ucomment when the bug is fixed.

Note: See TracTickets for help on using tickets.