def __init__( self, problem, targets, cmin, cmax, cstep=None, crossval=5, plotflag=False, maxdepth=8, searchlog="gridsearch_results.txt", **params ): """ Set up (log) grid search over the two RBF kernel parameters C and gamma. @param problem: the LIBSVM svm_problem to be optimized, ie. the input and target data @param targets: unfortunately, the targets used in the problem definition have to be given again here @param cmin: lower left corner of the log2C/log2gamma window to search @param cmax: upper right corner of the log2C/log2gamma window to search @param cstep: step width for log2C and log2gamma (ignored for DOE search) @param crossval: split dataset into this many parts for cross-validation @param plotflag: if True, plot the error surface contour (regular) or search pattern (DOE) @param maxdepth: maximum window bisection depth (DOE only) @param searchlog: Save a list of coordinates and the achieved CV accuracy to this file @param others: ...are passed through to the cross_validation method of LIBSVM """ self.nPars = len(cmin) self.usermin = cmin self.usermax = cmax self.userstep = cstep self.crossval = crossval self.plotflag = plotflag self.maxdepth = maxdepth # number of zoom-in steps (DOE search only!) # set default parameters for training self.params = params if self.plotflag: import pylab as p p.ion() p.figure(figsize=[12, 8]) assert isinstance(problem, svm_problem) self.problem = problem self.targets = targets self.resfile = open(searchlog, "w") # do the parameter searching param = self.search() if self.plotflag: p.ioff() p.show() self.resfile.close() svm_model.__init__(self, problem, param)
def __init__(self, problem, targets, cmin, cmax, cstep=None, crossval=5, plotflag=False, maxdepth=8, searchlog='gridsearch_results.txt', **params): """ Set up (log) grid search over the two RBF kernel parameters C and gamma. :arg problem: the LIBSVM svm_problem to be optimized, ie. the input and target data :arg targets: unfortunately, the targets used in the problem definition have to be given again here :arg cmin: lower left corner of the log2C/log2gamma window to search :arg cmax: upper right corner of the log2C/log2gamma window to search :key cstep: step width for log2C and log2gamma (ignored for DOE search) :key crossval: split dataset into this many parts for cross-validation :key plotflag: if True, plot the error surface contour (regular) or search pattern (DOE) :key maxdepth: maximum window bisection depth (DOE only) :key searchlog: Save a list of coordinates and the achieved CV accuracy to this file :key others: ...are passed through to the cross_validation method of LIBSVM """ self.nPars = len(cmin) self.usermin = cmin self.usermax = cmax self.userstep = cstep self.crossval = crossval self.plotflag = plotflag self.maxdepth = maxdepth # number of zoom-in steps (DOE search only!) # set default parameters for training self.params = params if self.plotflag: import pylab as p p.ion() p.figure(figsize=[12, 8]) assert isinstance(problem, svm_problem) self.problem = problem self.targets = targets self.resfile = open(searchlog, 'w') # do the parameter searching param = self.search() if self.plotflag: p.ioff() p.show() self.resfile.close() svm_model.__init__(self, problem, param)