Ticket #1330 (closed bug: fixed)

Opened 10 months ago

Last modified 8 months ago

Filter fails when comparing some continuous values

Reported by: Elaugaufein Owned by: Ales Erjavec <ales.erjavec@…>
Milestone: Component: library
Severity: minor Keywords: filter
Cc: Blocking:
Blocked By:

Description (last modified by Elaugaufein) (diff)

I was using code to create an instance and check if it was already in either of 2 tables before adding it to one of them , if it was in neither.

I put together some code that would create an instance and a filter but in testing the filter failed to generate any hits when applied to a test table with an instance drawn from that table using random_instance.

Further testing shows that the filter works with discrete values and with some continuous values (eg 1.0 works fine) but not with continuous values of arbitrary length (e.g comparing -0.04669319838285446 fails ). The comparison done by filter to instances in the table seems to be different to the true value of an instance. This also means that a filter to find a specific value in a table may fail.

The data set consists of 8 continuous variables, and a discrete class variable that is 0 or 1.

The code I was using follows:

def add(self,particle):
        if not max(particle.objectives) < 100.0:
            v =0;
	else:
            v = 1;

	domain = self.trainingTable.domain  
	instance = Orange.data.Instance(domain,particle.parameters + [v])
	filter = Orange.data.filter.Values()
	filter.domain = domain
	for i in instance.domain.features: 			
		filter.conditions.append(Orange.data.filter.ValueFilterContinuous(position=instance.domain.features.index(i),oper=Orange.data.filter.ValueFilter.Equal,ref=instance[instance.domain.features.index(i)].value))
	filter.conditions.append(Orange.data.filter.ValueFilterDiscrete(position=domain.index(domain.class_var),values=[Orange.data.Value(domain.class_var,v)]))

Change History

comment:1 Changed 10 months ago by Elaugaufein

  • Description modified (diff)

comment:2 Changed 8 months ago by Ales Erjavec <ales.erjavec@…>

  • Owner set to Ales Erjavec <ales.erjavec@…>
  • Status changed from new to closed
  • Resolution set to fixed

In [e2f72ce88fed19cdd628da747918424c927648b7/orange]:

Fixed equality operator for continuous filters.

(fixes #1330)

Note: See TracTickets for help on using tickets.