Ticket #324 (closed wish: fixed)

Opened 5 years ago

Last modified 5 years ago

orange.Example naj sprejme tudi vrednosti None

Reported by: blaz Owned by: janez
Milestone: 2.6 Component: library
Severity: minor Keywords:
Cc: Blocking:
Blocked By:

Description

orange.Example sprejme listo vrednosti, katerih element je lahko None le za string atribute, sicer pa (za Continuous in Discrete) mora biti definirana. Enako velja za razredno spremljivko.

Ali lahko spremenis tako, da tudi za Continuous in Discrete atribute lahko podamo vrednosti None. V tem primeru je vrednost atributa unknown.

Spodnja skripta kaze, kako to ze dela za string atribute, a se zadeva razsuje pri predzadnjem zadnjem klicu (None za zvezni atribut; tudi zadnji klic za diskretni razred ne dela):

import orange
data = orange.ExampleTable("iris")
id = orange.StringVariable("id")
newdomain = orange.Domain(data.domain.attributes + [id, data.domain.classVar])
data = orange.ExampleTable(newdomain, data)
for i, d in enumerate(data):
    d[id] = str(i)
    
print data[0] 

ex = orange.Example(data.domain, [10, 20, 30, 40, "mico", 0])
print ex
ex = orange.Example(data.domain, [10, 20, 30, 40, None, 0])
print ex
ex = orange.Example(data.domain, [None, 20, 30, 40, None, 0])

# class should be set to undefined as well
print ex
ex = orange.Example(data.domain, [50, 20, 30, 40, None, None])

Poganjanje skripte da:

> bug-no-class.py
[5.1, 3.5, 1.4, 0.2, '0', 'Iris-setosa']
[10.0, 20.0, 30.0, 40.0, 'mico', 'Iris-setosa']
[10.0, 20.0, 30.0, 40.0, '?', 'Iris-setosa']
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

d:\Documents\Workspace\kmeans\src\bug-no-class.py in <module>()
     13 ex = orange.Example(data.domain, [10, 20, 30, 40, None, 0])
     14 print ex
---> 15 ex = orange.Example(data.domain, [None, 20, 30, 40, None, 0])
     16
     17

TypeError: attribute no. 1 (sepal length) is continuous, float value expected
WARNING: Failure executing file: <bug-no-class.py>

Change History

comment:1 Changed 5 years ago by blaz

  • Severity changed from immediate to minor

comment:2 Changed 5 years ago by janez

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.