Exemplo n.º 1
0
	def test_load(self):
		examples = train_example.load()

		print("X length: ", len(examples[0].x))
		print("Y length: ", len(examples[0].y))

		self.assertEqual(len(examples), 372)
Exemplo n.º 2
0
def calibration():
    """Calibrates the model.

    It uses default values for epochs and n-folds.
    """
    examples = train_example.load()

    # Split examples in train and validation using 5-fold
    print("examples size:", len(examples))
    kf = KFold(len(examples), n_folds=5)

    wLength = len(examples[0].x[0].coref.feat)

    for trainIndex, testIndex in kf:
        train = [examples[e] for e in trainIndex]
        print("\n\ntrain size:", len(train))
        validation = [examples[e] for e in testIndex]
        print("validation size:", len(validation))

        w = np.array([0] * wLength)

        w = perceptron.structured(w,
                                  train,
                                  test=validation,
                                  epochs=65,
                                  argmax=quotation.argmax,
                                  phi=quotation.phi)
Exemplo n.º 3
0
    def test_load(self):
        examples = train_example.load()

        print("X length: ", len(examples[0].x))
        print("Y length: ", len(examples[0].y))

        self.assertEqual(len(examples), 372)
Exemplo n.º 4
0
def main():
    """Main function, that train and validade the model for the Quotation Extractor Task.

    """
    w = train.train()
    print(w)

    dataset = train_example.load(fileName=INPUT_TEST_FILE)

    precision, recall = metrics.validate(w, dataset=dataset, argmax=quotation.argmax)

    print("On the test set:\n")
    print("precision:", precision)
    print("recall:", recall)
Exemplo n.º 5
0
def main():
    """Main function, that train and validade the model for the Quotation Extractor Task.

    """
    w = train.train()
    print(w)

    dataset = train_example.load(fileName=INPUT_TEST_FILE)

    precision, recall = metrics.validate(w,
                                         dataset=dataset,
                                         argmax=quotation.argmax)

    print("On the test set:\n")
    print("precision:", precision)
    print("recall:", recall)
Exemplo n.º 6
0
def train():
	"""Train the model, based of the default GloboQuotes dataset.

    Returns:
        The w model trained.
    """
	examples = train_example.load()

	# Split examples in train and validation using 5-fold
	print("examples size:", len(examples))

	wLength = len(examples[0].x[0].coref.feat)
	w = np.array([0]*wLength)

	w = perceptron.structured(w, examples, test=None, epochs=38, argmax=quotation.argmax, phi=quotation.phi)

	return w
Exemplo n.º 7
0
def calibration():
	"""Calibrates the model.

    It uses default values for epochs and n-folds.
    """
	examples = train_example.load()

	# Split examples in train and validation using 5-fold
	print("examples size:", len(examples))
	kf = KFold(len(examples), n_folds=5)

	wLength = len(examples[0].x[0].coref.feat)

	for trainIndex, testIndex in kf:
		train = [ examples[e] for e in trainIndex ]
		print("\n\ntrain size:", len(train))
		validation = [ examples[e] for e in testIndex ]
		print("validation size:", len(validation))

		w = np.array([0]*wLength)

		w = perceptron.structured(w, train, test=validation, epochs=65, argmax=quotation.argmax, phi=quotation.phi)
Exemplo n.º 8
0
def train():
    """Train the model, based of the default GloboQuotes dataset.

    Returns:
        The w model trained.
    """
    examples = train_example.load()

    # Split examples in train and validation using 5-fold
    print("examples size:", len(examples))

    wLength = len(examples[0].x[0].coref.feat)
    w = np.array([0] * wLength)

    w = perceptron.structured(w,
                              examples,
                              test=None,
                              epochs=38,
                              argmax=quotation.argmax,
                              phi=quotation.phi)

    return w