Orange Forum • View topic - regression using orngTest

regression using orngTest

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.

regression using orngTest

Postby Guest » Wed Jun 14, 2006 9:20

When undertaking regression, the results returned from functions in orngTest have the class value as an int rather than a float. This results in errors in the calculation of how good the model is e.g. using MSE.

e.g. in orngTest (line 451 in function testOnData)

te = TestedExample(iterationNumber, int(ex.getclass()), 0, ex.getweight(testweight))

The 'int(ex.getclass())' is where the problem stems from. This is all the testing methods.

Postby Janez » Wed Jun 14, 2006 12:56

Thanks for the report about this ugly bug. It seems that we never tried regression on data with values from [0, 1], so we haven't spotted the bug. (We seldom use regression anyway, that's why Orange has so little of it.)

I think that this

Code: Select all
    conv = testset.domain.classVar.varType == orange.VarTypes.Discrete and int or float
    for ex in testset:
        te = TestedExample(iterationNumber, conv(ex.getclass()), 0, ex.getweight(testweight))


should do the trick. Please tell me if it doesn't. (But judging by your bug report you have probably fixed the code with something like this yourself).

Postby Guest » Fri Jun 16, 2006 7:09

Hi,

I just checked out the latest snapshot with the changes you describe. The testOnData function now works properly, but leaveOneOut does not.

Line 308 in testWithIndices:
Code: Select all
testResults.results = [TestedExample(indices[i], int(examples[i].getclass()), nLrn, examples[i].getweight(weight)) for i in range(len(examples))]


probably need to be replaced with something like this:

Code: Select all
conv = examples.domain.classVar.varType == orange.VarTypes.Discrete and int or float
testResults.results = [TestedExample(indices[i], conv(examples[i].getclass()), nLrn, examples[i].getweight(weight)) for i in range(len(examples))]


Thanks for the great code to play with!

Postby Janez » Fri Jun 16, 2006 8:45

Thanks. I found one more, in learningCurve (around line 215).

Janez


Return to Bugs