123456789101112131415161718192021222324252627282930 |
- #! /usr/bin/python
- import numpy
- import pickle
- import sys
- import os
- sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),os.pardir))
- import helperFunctions
- import activeLearningWlinGPprototype
- class Classifier(activeLearningWlinGPprototype.ClassifierPrototype):
- def __init__(self, sigmaN = 0.00178, loNoise = True, configFile=None):
- activeLearningWlinGPprototype.ClassifierPrototype.__init__(self, sigmaN=sigmaN, configFile=configFile)
- self.loNoise = helperFunctions.getConfig(configFile, 'activeLearning', 'loNoise', loNoise, 'bool', True)
- # x.shape = (number of samples, feat dim)
- def calcAlScores(self, x):
- loNoise = (self.yUni == -1).any() and self.loNoise
- sortedScores = numpy.sort(self.infer(x, loNoise), axis=1)
- alScores = numpy.abs(sortedScores[:,-1] - sortedScores[:,-2])
- # since we actually want to select min(scores) instead of max(scores), we have to turn the scores around
- return numpy.add(numpy.subtract(alScores, numpy.max(alScores))*(-1.0), numpy.finfo(numpy.float32).eps)
|