Пример #1
0
	def grid_search(self, kernel, labels, C_range=(-15, 15), gamma_range=(-15, 15)):
		C_min = C_range[0]
		C_max = C_range[1]
		params = {'C': [2 ** i for i in range(C_min, C_max, 1)]}
		if gamma_range:
			gamma_min = gamma_range[0]
			gamma_max = gamma_range[1]
			params['gamma'] = [2 ** i for i in range(gamma_min, gamma_max, 1)]
		data = VectorCreator.make_vectors(self.preprocessor, self.n_chars_extractor, self.pos_tag_extractor)
		return ClassifierBase.grid_search(SVC(kernel=kernel), data, labels, params)
Пример #2
0
	def train(self, kernel, params):
		C = params['C']
		gamma = params['gamma']
		svc = SVC(C=C, gamma=gamma, kernel=kernel)
		data = VectorCreator.make_vectors(self.preprocessor, self.n_chars_extractor, self.pos_tag_extractor)
		ClassifierBase.train(svc, data)