original_docstring: 
  		Train on the provided data with the perceptron algorithm.
  		Up to self.MAX_ITERATIONS of learning.
  		At the end of training, self.weights should contain the final model
  		parameters.
  		
docstring: Train on the provided data with the perceptron algorithm.
  Up to self.MAX_ITERATIONS of learning.
  At the end of training, self.weights should contain the final model
  parameters.
docstring_tokens: Train on the provided data with the perceptron algorithm . Up to self . MAX_ITERATIONS of learning . At the end of training self . weights should contain the final model parameters .
code: def learn(self, train_docs, train_labels):
  		"""
  		Train on the provided data with the perceptron algorithm.
  		Up to self.MAX_ITERATIONS of learning.
  		At the end of training, self.weights should contain the final model
  		parameters.
  		"""
  		for i in range(self.MAX_ITERATIONS):
  			for j in range(len(train_docs)):
  				if self.predict(train_docs[j]) != train_labels[j]:
  					for word in train_docs[j]:
  						self.weights[train_labels[j]][word] += 1 # change value to 2 if doing subtract all
  						# subtract all others is too slow to implement
  						# for k in range(len(self.CLASSES)):
  						# 	self.weights[train_labels[k]][word] -= 1
  					self.weights[train_labels[j]]['g_bias'] += 1 # change value to 2 if doing subtract all
  					# subtract all others is too slow to implement
  					# for k in range(len(self.CLASSES)):
  					# 	self.weights[train_labels[k]]['g_bias'] -= 1
  			# uncomment below lines for iteration analysis
  			# print (str(i), str(self.test_eval(train_docs, train_labels)),
  			# 	str(self.test_eval(self.dev_docs, self.dev_labels)), sep=',')
  			print ('iter'+str(i), file=sys.stderr)
code_tokens: def learn ( self , train_docs , train_labels ) : for i in range ( self . MAX_ITERATIONS ) : for j in range ( len ( train_docs ) ) : if self . predict ( train_docs [ j ] ) != train_labels [ j ] : for word in train_docs [ j ] : self . weights [ train_labels [ j ] ] [ word ] += 1 self . weights [ train_labels [ j ] ] [ 'g_bias' ] += 1 print ( 'iter' + str ( i ) , file = sys . stderr )
short_docstring: Train on the provided data with the perceptron algorithm.
short_docstring_tokens: Train on the provided data with the perceptron algorithm .
comment: """
  		Train on the provided data with the perceptron algorithm.
  		Up to self.MAX_ITERATIONS of learning.
  		At the end of training, self.weights should contain the final model
  		parameters.
  		"""$SEP$# change value to 2 if doing subtract all$SEP$# subtract all others is too slow to implement$SEP$# for k in range(len(self.CLASSES)):$SEP$# 	self.weights[train_labels[k]][word] -= 1$SEP$# change value to 2 if doing subtract all$SEP$# subtract all others is too slow to implement$SEP$# for k in range(len(self.CLASSES)):$SEP$# 	self.weights[train_labels[k]]['g_bias'] -= 1$SEP$# uncomment below lines for iteration analysis$SEP$# print (str(i), str(self.test_eval(train_docs, train_labels)),$SEP$# 	str(self.test_eval(self.dev_docs, self.dev_labels)), sep=',')