Ticket #1330 (closed bug: fixed)
Filter fails when comparing some continuous values
|Reported by:||Elaugaufein||Owned by:||Ales Erjavec <ales.erjavec@…>|
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)]))