Orange Forum • View topic - TypeError while selecting elements in a Confusion Matrix

TypeError while selecting elements in a Confusion Matrix

Report bugs (or imagined bugs).
(Archived/read-only, please use our ticketing system for reporting bugs and their discussion.)
Forum rules
Archived/read-only, please use our ticketing system for reporting bugs and their discussion.

TypeError while selecting elements in a Confusion Matrix

Postby acameron » Tue Nov 10, 2009 16:24

After starting up Orange Canvas, these are the contents of the output window:
Code: Select all
There were problems importing the following widgets:
OWCorrAnalysis: No module named qttable
OWSimon: No module named qt
The following widgets could not be imported and will not be available: OWCorrAnalysis.
The following prototype widgets could not be imported and will not be available: OWSimon.

After opening a simple schema:
Code: Select all
file --> data dampler --> test learners --> confusion matrix

(I hope that ASCII art worked)

And then loading a file (I was using one with data I have measured, but it's reproducible with, e.g.,, whenever I click on any of the entries in the Confusion Matrix, the Output Window shows this:
Code: Select all
Unhandled exception of type TypeError occured at 10:17:55:
  File:, line 61 in __call__
  Code: self.method(*k)
    File:, line 213 in sendIf
    Code: self.sendData()
      File:, line 237 in sendData
      Code: predVar = type(domain.classVar)("%s(%s)" % (, self.learnerNames[learnerI]))
        TypeError: orange.EnumVariable: 'unicode' is not a subtype of 'orange.EnumVariable'

I've tried peeking at some of the Python source but the dynamic typing is getting the better of my, I'm afraid, and I can't quite figure out what's going wrong and where.

Technical details:
    Running Ubuntu 9.10
    Performed a fresh download of a nightly build yesterday, and compiled from source
    Patched the Qwt bug yesterday (cf. this topic)
    Ran "sudo python /usr/lib/python2.6/dist-packages/orange/" just this morning

Thanks in advance for your help! If there's anything I can do to assist, I am eager and willing.

(On a side note, try as I might, I can't seem to find a "Register" link to create an account on these forums. Any help on this would also be appreciated!)

Postby acameron » Tue Nov 10, 2009 16:26

*getting the better of me

Postby acameron » Tue Nov 10, 2009 18:17

So, after some digging around, is of type 'str', whereas self.learnerNames[learnerI] is of type 'unicode'. This is what's causing the problem on line 237. With some wonderful help from the folks in #Python on, I figured out to edit line237 so that it appears like so:
Code: Select all
                predVar = type(domain.classVar)("%s(%s)" % (, self.learnerNames[learnerI].encode("utf-8")))

This fixes the problem.

(Can I have a cookie?)

Postby acameron » Tue Nov 10, 2009 23:54

Um, so, I don't have write access to the SVN repository, but here's a patch for the fix:

Code: Select all
From ad3ea2a05f35834f807be53a2b25c42f807e8164 Mon Sep 17 00:00:00 2001
From: Andrew Cameron <>
Date: Tue, 10 Nov 2009 17:49:15 -0500
Subject: [PATCH] fixed encoding problem in Confusion Matrix

Signed-off-by: Andrew Cameron <>
 orange/OrangeWidgets/Evaluate/ |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/orange/OrangeWidgets/Evaluate/ b/orange/OrangeWidgets/Evaluate/
index b289467..2025b6d 100644
--- a/orange/OrangeWidgets/Evaluate/
+++ b/orange/OrangeWidgets/Evaluate/
@@ -234,7 +234,7 @@ class OWConfusionMatrix(OWWidget):
             data = orange.ExampleTable(domain, data)
             if self.appendPredictions:
-                predVar = type(domain.classVar)("%s(%s)" % (, self.learnerNames[learnerI]))
+                predVar = type(domain.classVar)("%s(%s)" % (, self.learnerNames[learnerI].encode("utf-8")))
                 if hasattr(domain.classVar, "values"):
                     predVar.values = domain.classVar.values
                 predictionsId = orange.newmetaid()

Please let me know if this is useful, or if I can help contribute to Orange in some other way.

Postby Janez » Wed Nov 11, 2009 0:01

Great, thanks.

I added this fix to the svn. Unfortunately it's rather temporary: we have a great unicode/ascii chaos now, and we're gonna have lots of problems cleaning it when we move to Python 3.0 some day.


Return to Bugs