def getProb(trainD, trainC, testD , lrn): orangeData = funkcije.listToOrangeSingleClass(trainD+testD, trainC+[0]*len(testD)) ind = [1]*len(trainD)+[0]*len(testD) orangeTrainD = orangeData.select_ref(ind,1) orangeTestD = orangeData.select_ref(ind,0) cl = lrn(orangeTrainD) return [cl(i, Orange.classification.Classifier.GetProbabilities)[True] for i in orangeTestD]
def getProb(trainD, trainC, testD, lrn): orangeData = funkcije.listToOrangeSingleClass(trainD + testD, trainC + [0] * len(testD)) ind = [1] * len(trainD) + [0] * len(testD) orangeTrainD = orangeData.select_ref(ind, 1) orangeTestD = orangeData.select_ref(ind, 0) cl = lrn(orangeTrainD) return [ cl(i, Orange.classification.Classifier.GetProbabilities)[True] for i in orangeTestD ]
def reliefFilter(trainD, trainC): orangeData = funkcije.listToOrangeSingleClass(trainD, trainC) meas = Orange.feature.scoring.Relief() mr = [ (a.name, meas(a, orangeData)) for a in orangeData.domain.attributes] mr.sort(key=lambda x: -x[1]) #sort decreasingly by the score return [i[0] for i in mr]
def reliefFilter(trainD, trainC): orangeData = funkcije.listToOrangeSingleClass(trainD, trainC) meas = Orange.feature.scoring.Relief() mr = [(a.name, meas(a, orangeData)) for a in orangeData.domain.attributes] mr.sort(key=lambda x: -x[1]) #sort decreasingly by the score return [i[0] for i in mr]