Ticket #299 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

knn learnerju ne uspem podati novega distance construkturja

Reported by: marko Owned by: janez
Milestone: Future Component: library
Severity: major Keywords:
Cc: Blocking:
Blocked By:

Description

Želel sem zglraditi nov distance constructor, ki bi ga podal knn learnerju.

Naslednja koda mi poda Segmentation fault:

import orange

data = orange.ExampleTable('../iris.tab')

class PearsonDistance(object):

    def __init__(self, examples):
        pass

    def __call__(self, *args):
        return 1.0

def PDC(examples, *args, **kwargs):
    return PearsonDistance(examples)

distanceConstructors = [  "orange.ExamplesDistanceConstructor_Hamming()" ]

print "Hamming"
knn = orange.kNNLearner(k=10, distanceConstructor=orange.ExamplesDistanceConstructor_Hamming())
knnc = knn(data)
print "result:",
print knnc(data[0])
print "PDC"
knn = orange.kNNLearner(k=10, distanceConstructor=PDC)
knnc = knn(data)
print "result:",
print knnc(data[0])

Output:

Hamming
result: Iris-setosa
PDC
Segmentation fault

Change History

comment:1 Changed 6 years ago by janez

V gornji skripti bi moralo namesto

class PearsonDistance(object)

pisati

class PearsonDistance(orange.ExamplesDistance)

V tem konkretnem primeru bi Orange sicer lahko zavil to, kar je dobil, v pravi tip, vendar tega v vecini podobnih primerov ne more, zato tudi tu zahteva (in bo zahteval), da je rezultat klica ExamplesDistanceConstructorja objekt pravega tipa (se pravi nekaj, kar je izpeljano iz ExamplesDistance).

Grdo pa je, da se je zaradi tega sesul, namesto da bi javil napako. V drugih podobnih situacijah javlja napako, v tej pa ni preveril tipa. Sem popravil.

comment:2 Changed 6 years ago by marko

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