Example #1
0
from exp.modelselect.ModelSelectUtils import ModelSelectUtils 
from sandbox.util.Sampling import Sampling
from apgl.predictors.LibSVM import LibSVM
import matplotlib.pyplot as plt 

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
numpy.seterr(all="raise")
numpy.random.seed(21)
dataDir = PathDefaults.getDataDir() 
dataDir += "modelPenalisation/regression/"
outputDir = PathDefaults.getOutputDir() + "modelPenalisation/regression/SVR/"

figInd = 0 

loadMethod = ModelSelectUtils.loadRegressDataset
datasets = ModelSelectUtils.getRegressionDatasets(True)

numProcesses = multiprocessing.cpu_count()
learner = LibSVM(kernel="rbf", processes=numProcesses, type="Epsilon_SVR")
learner.setChunkSize(3)

Cs = 2.0**numpy.arange(-10, 14, 2, dtype=numpy.float)
gammas = 2.0**numpy.arange(-10, 4, 2, dtype=numpy.float)
epsilons = learner.getEpsilons()

gammaInd = 3 
gamma = gammas[gammaInd]
learner.setGamma(gamma)

epsilonInd = 0 
epsilon = epsilons[epsilonInd]
Example #2
0
showCART = True  
showSVR = False 

from itertools import cycle
lines = ["k-","k--","k-.","k:","k-x", "k-+"]
linecycler = cycle(lines)


if showSVR: 
    outputDir = PathDefaults.getOutputDir() + "modelPenalisation/regression/SVR/"
    
    sampleSizes = numpy.array([50, 100, 200])
    sampleMethods = ["CV"]
    cvScalings = numpy.arange(0.6, 1.61, 0.2)
    foldsSet = numpy.arange(2, 13, 2)
    datasetNames = ModelSelectUtils.getRegressionDatasets()
    fileNameSuffix = 'Results'
    summary(datasetNames, sampleSizes, foldsSet, cvScalings, sampleMethods, fileNameSuffix)
    
    plotDatasetNames = [datasetNames[7]]
    plotAlphas(plotDatasetNames, sampleSizes, foldsSet, cvScalings, sampleMethods, fileNameSuffix)    
    
    sampleSizes = numpy.array([25, 50, 100])
    sampleMethods = ["CV"]
    cvScalings = numpy.arange(0.6, 1.61, 0.2)
    foldsSet = numpy.arange(10, 51, 10)
    datasetNames = ModelSelectUtils.getRegressionDatasets()
    fileNameSuffix = "ResultsExt"
    summary(datasetNames, sampleSizes, foldsSet, cvScalings, sampleMethods, fileNameSuffix, "GridResultsExt")
    
    
Example #3
0
import matplotlib.pyplot as plt 
from apgl.util import Evaluator 
import sklearn.metrics 

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
numpy.seterr(all="raise")
numpy.random.seed(45)
numpy.set_printoptions(linewidth=150)
dataDir = PathDefaults.getDataDir() 
dataDir += "modelPenalisation/regression/"
outputDir = PathDefaults.getOutputDir() + "modelPenalisation/regression/SVR/"

figInd = 0 

loadMethod = ModelSelectUtils.loadRegressDataset
datasets = ModelSelectUtils.getRegressionDatasets(True)
datasetName = datasets[9][0]

#sampleSizes = numpy.array([50, 100, 200])
sampleSizes = numpy.array([50, 100, 150, 200, 250, 300])
foldsSet = numpy.arange(2, 13, 1)
alpha = 1.0

Cs = 2.0**numpy.arange(-10, 14, 2, dtype=numpy.float)
gammas = 2.0**numpy.arange(-10, 4, 2, dtype=numpy.float)
epsilons = numpy.array([2**-2])

paramDict = {} 
paramDict["setC"] = Cs 
paramDict["setGamma"] = gammas
paramDict["setEpsilon"] = epsilons